Rank
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 324 Accepted Submission(s): 175
Problem Description
Recently in Teddy's hometown there is a competition named "Cow Year Blow Cow".N competitors had took part in this competition.The competition was so intense that the rank was changing and changing.
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
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
Input
The first line will contain a T,then T cases followed.
each case only contain one integer N (N <= 100),indicating the number of people.
each case only contain one integer N (N <= 100),indicating the number of people.
Output
One integer pey line represent the answer MOD 20090126.
Sample Input
2 2 3
Sample Output
3 13
Author
teddy
Source
Recommend
题目大意:给个n,n个人的排名总共有多少种方式,用斯特林第二类数求得把n个数分成k组的值,分的组,就是等级相等的,然后再成k的全排列就是k组相等的情况数了,然后加上所有k的情况就可以了,
ac代码
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define mod 20090126
#define LL long long
using namespace std;
LL s[110][110],fac[110];
LL ans[110];
void fun()
{
int i,j;
fac[0]=1;
for(i=1;i<110;i++)
fac[i]=(fac[i-1]*i)%mod;
for(i=1;i<110;i++)
{
s[i][i]=1;
s[i][0]=0;
for(j=1;j<i;j++)
{
s[i][j]=(s[i-1][j-1]+j*s[i-1][j]%mod)%mod;
}
}
for(i=1;i<110;i++)
{
ans[i]=0;
for(j=0;j<=i;j++)
{
ans[i]=(ans[i]+s[i][j]*fac[j]%mod)%mod;
}
}
}
int main()
{
int t;
scanf("%d",&t);
fun();
while(t--)
{
int n;
scanf("%d",&n);
printf("%lld\n",ans[n]);
}
}