ZCMU-1518-两种全排列的题。

博客详细解释了如何解决全排列问题,特别是当N较大时如何避免使用next_permutation导致的时间超时。通过示例说明了如何找出特定顺序在全排列中的位置,包括两种类型的问题:一是给出顺序,求在全排列中的位置;二是已知位置,反推序列。
摘要由CSDN通过智能技术生成

链接:点击打开链接

1518: A Permutation Problem

Time Limit: 1 Sec   Memory Limit: 32 MB
Submit: 56   Solved: 17
[ Submit][ Status][ Web Board]

Description

A long time ago, there was a boy called ZDD. One day he studied the algorithm of permutation. The meaning of permutation is that choosing M different elements from N different elements, and arranged in a certain order. What’s more, if N=M, it’s called full permutation. For example, if N=3 and the sequence is “1 2 3”. The first permutation is “1 2 3”. The second permutation is “1 3 2”. The third permutation is “2 1 3”. The fourth permutation is “2 3 1”. The fifth permutation is “3 1 2”. And the last permutation is “3 2 1”. Now the problem is coming, Giving a sequence S with N elements, each element is in the range of [1,n], and each of them is different. Can you tell him what is the order number of this sequence in full permutation?

Input

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值