Lexicographic permutations

https://projecteuler.net/problem=24

Lexicographic permutations

Problem 24

Published on Friday, 16th August 2002, 06:00 pm; Solved by 75662; Difficulty rating: 5%

A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:

012   021   102   120   201   210

What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?

这道题懒得编程了,就纯粹靠手工计算的结果,过程如下:

9!=362880,我们要算第100万个,所以第一个数字排在第三位,也就是    2,接下来要算第274240位数 (1000000 - 9! * 2)

8!=40320,经过计算:8!*6 < 274240 < 8!*7,所以第二个数字,排在剩下数字的第7位,也就是:7,接下来算第32320位数(274240 - 8! * 6)

依次类推:直到剩下最后两位6和0,要求第二位数,那就是60了。

所以结果是:2783915460


用计算机算也一样,懒得写程序了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值