Problem Description
Problem Analysis
A combinatorics problem
First choose which positions from the positions
Then put the soldiers into them, empty allowed
From combinatorics we get
C(n+m-1,m-1)
Note that it is modulo 777
So use an array
Using $ CMI[i][j]=CMI[i-1][j-1]+CMI[i-1][j] $
to compute CMI is better
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| #include<stdio.h>
int CMI[101][101];
void GetCMI() {
for(int i=0; i<=100; i++)
CMI[i][0]=1;
for(int i=1; i<=100; i++) {
for(int j=1; j<=i; j++) {
CMI[i][j]=(CMI[i-1][j-1]+CMI[i-1][j])%777;
}
}
}
int main() {
GetCMI();
int N,M;
while(scanf("%d %d",&N,&M)!=EOF) {
int sum=0;
for(int i=1; i<=M; i++) {
sum=(sum+CMI[M][i]*CMI[N+i-1][i-1])%777;
}
printf("%d\n",sum);
}
return 0;
}
|
Problem address: [DidaOJ] [338] QAQ’s Problem