【2011 Greater New York Regional 】Problem H: Maximum in the Cycle of 1
2013-10-01 16:29
447 查看
也是一个数学题;
主要用到的是排列组合的知识,推推公式就行了,挺简单的;
唯一要注意的是A(0,0)=1;
在这个上面WA了几次,= =
代码:
View Code
主要用到的是排列组合的知识,推推公式就行了,挺简单的;
唯一要注意的是A(0,0)=1;
在这个上面WA了几次,= =
代码:
#include<stdio.h> #define ULL unsigned long long #define maxn 21 using namespace std; ULL C[maxn+5][maxn+5];//范围可向上变更 ULL A[maxn]; void builtC(){ memset(C,0,sizeof(C)); C[0][0]=1; for(int i=1;i<=maxn;i++){ C[i][0]=C[i][i]=1; for(int j=1;j<=i;j++){ C[i][j]=(C[i-1][j]+C[i-1][j-1]); } } return ; } void builtA() { ULL a=1; A[0]=1; for(int i=1;i<=20;i++) { a=a*i; A[i]=a; } } int main() { builtC(); builtA(); int t; while(~scanf("%d",&t)) { int cas,n,k; while(t--) { scanf("%d%d%d",&cas,&n,&k); ULL ans=0; if (k==1) {printf("%d %.0lf\n",cas,(double)A[n-1]);continue;} int sc1=n-k,sc2=k-1,sc3=k-2; while(sc1<=n-2) { ans+=A[sc1]*A[sc2]*C[k-2][sc3]; sc1++;sc2--;sc3--; } printf("%d %.0lf\n",cas,(double)ans); } } return 0; }
View Code
相关文章推荐
- 【2011 Greater New York Regional 】Problem I :The Golden Ceiling
- 【2011 Greater New York Regional 】Problem G: Rancher's Gift
- Problem A - Sum Kind Of Problem 2015 ACM/ICPC Greater New York Region
- HDU_4243_Maximum in the Cycle of 1(置换群)
- 【2011 Greater New York Regional 】Problem B The Rascal Triangle
- A cycle was detected in the build path of project Build path Build Path Problem(Eclipse)
- shining cento in book reading: handle out of memory problem for new operator -by register a global SetNewHandler
- A cycle was detected in the build path of project
- Increasing the maximum number of tcp/ip connections in linux
- How do I make my GUI plot into an axes within the GUI figure rather than inside of a new figure in M
- New influence in American Life -- The roles of man and woman changing
- 2010-2011 ACM-ICPC, NEERC, Southern Subregional Contest Fire in the Country(博弈论+搜索)
- A cycle was detected in the build path of project 感叹号
- An instance of getting the maximum and minimum values in an array
- Eclipse Error:A cycle was detected in the build path of project
- 复制单链表成为新的链表,然后return the number of items in the new list
- Major Problem in the Process of Urbanization
- 项目文件夹出现红色感叹号:A cycle was detected in the build path of project
- flex/in the datagrid,how to get the new value of cell in the datagrid after edit
- Deprecated: Assigning the return value of new by reference is deprecated in……【解决方法】