HDU_4243_Maximum in the Cycle of 1(置换群)
来源:互联网 发布:梦幻西游手游捉鬼软件 编辑:程序博客网 时间:2024/05/31 13:16
Description
If P is a permutation of the integers 1,..., n, the maximum in the cycle of 1 is the maximum of the values P(1), P(P(1)), P(P(P(1))), etc. For example, if P is the permutation:
|1 2 3 4 5 6 7 8||3 2 5 4 1 7 8 6|
we have:
For this problem, you will write a program which takes as input integers n, (n > 0) and k ( 1kn), and returns the number of permutations of the integers 1,..., n, for which the maximum in the cycle of 1 is k.
Input
The first line of inputcontains a single integer P, ( 1P1000), which is the number of data sets that follow. Each data set is a single line that contains the three space separated decimal integer values. The first value is the data set number, N. The second value is the size of the permutation, n where ( 1n20), and the third value is the desired maximum in the cycle of 1, k where ( 1kn).
Output
For each data set there is one line of output. It contains the data set number (N) followed by a single space, followed by a double precision floating point whole value which is the number of permutations of the integers 1,..., n, for which the maximum in the xycle of 1 is k.
Sample Input
41 4 12 7 33 10 54 20 7
Sample Output
1 62 1683 864004 11585247657984000
题型:组合数学、离散代数系统
题意:还是不怎么懂的说。。。
分析:貌似用到离散中置换群的概念,还是先去学学离散之后再议,(还是队友比较给力,暂且将代码留下,过会儿慢慢研究)。
代码:
#include<iostream>#include<algorithm>#include<string.h>#include<stack>#include<queue>#include<math.h>#include<cstdio>#define mem(a,b) memset(a,b,sizeof(a))using namespace std;const int maxn=500;const int inf=0x7fffff;double A(double x){double r=1;for(double i=1;i<=x;i++)r*=i;return r;}double C(double m,double n){double r=1;for(double i=n-m+1;i<=n;i++)r*=i;for(double i=m;i>=1;i--)r/=i;return r;}int main(){int t,a;double n,m;scanf("%d",&t);while(t--){scanf("%d%lf%lf",&a,&n,&m);double ans=0;if(m==1) ans+=A(n-1);else for(double i=1;i<m;i++){if(i==1)ans+=A(n-2);else ans+=A(n-1-i)*A(i)*C(i-1,m-2);}printf("%d %0.lf\n",a,ans);}return 0;}
- HDU_4243_Maximum in the Cycle of 1(置换群)
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project
- A cycle was detected in the build path of project 'core'. The cycle consists of projects {core, sms}
- UARs For The Cycle Bin In Windows -1
- Eclipse Error:A cycle was detected in the build path of project
- 【转】A cycle was detected in the build path of project:
- A cycle was detected in the build path of project Build path Build Path Problem(Eclipse)
- 解决 A cycle was detected in the build path of project 问题
- Eclipse问题 A cycle was detected in the build path of project: XXX
- A cycle was detected in the build path of project eclipse中target没有classes文件
- spring mvc + mybatis + spring aop声明式事务管理没有作用
- u盘中Trojan.Generic病毒
- TF-IDF 余弦相似度
- vs2010中静态调用dll
- 直接拿来用,10个PHP代码片段
- HDU_4243_Maximum in the Cycle of 1(置换群)
- 正则表达式30分钟入门教程
- linux内核学习笔记——持久映射
- android 其他技术总结
- UVA 10115 - Automatic Editing(字符串)
- EAS BOS 在list界面增加过滤、排序及删除默认的过滤条件
- UVa748 Exponentiation
- TCP详解----可靠数据传输原理(二)
- 我想念的提高班