Rank
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 399 Accepted Submission(s): 193
Now the question is:
How many different ways that n competitors can rank in a competition, allowing for the possibility of ties.
as the answer will be very large,you can just output the answer MOD 20090126.
Here are the ways when N = 2:
P1 < P2
P2 < P1
P1 = P2
each case only contain one integer N (N <= 100),indicating the number of people.
2 2 3
313
AC代码:
#include <iostream> #include <cstdio> #include <algorithm> #define LL __int64 #define MOD 20090126 using namespace std; LL str[101][101]; LL con[101]; void initial() { con[0]=1; for(LL i=1;i<=100;i++) con[i]=(con[i-1]*i)%MOD; for(LL i=0;i<=100;i++) { for(LL j=0;j<=i;j++) { if(i==j) str[i][j]=1; else if(j==0&&i>=1) str[i][j]=0; else { str[i][j]=((j*str[i-1][j])%MOD+str[i-1][j-1])%MOD; } } } } int main() { initial(); LL n,T; scanf("%I64d",&T); while(T--) { scanf("%I64d",&n); LL ans=0; for(LL i=1;i<=n;i++) ans=(ans+(str[n][i]*con[i])%MOD)%MOD; printf("%I64d\n",ans); } return 0; }