Original question
Description
We know that in programming, we often need to take into account the complexity of time, especially for the loop part. For example
If the code appears
for (i=1;i<=n;i++) OP;
Then do the N-Times op operation if the code appears
fori=1;i<=n; i++)
for (j=i+1;j<=n; j + +) OP;
Then do N (n-1)/2 op operation.
Now you are given an M-layer for loop operation, and each time the start value of the variable in for is the starting value of the previous variable +1 (the first variable starts with a value of 1), the terminating value is an input n, and the last OP has a total amount of computation.
Input
There are T group case,t<=10000. Each case has two integers m and n,0<m<=2000,0<n<=2000.
Output
For each case, output a value that represents the total amount of computation, perhaps the number is large, then you only need to output the remainder of the 1007 left.
Sample Input
21 32 3
Sample Output
33 My Code:
#include <iostream>#include<cstdio>using namespacestd;intch[2500][2500];intMain () {intI, J; for(i =1; I <= -; i++) {Ch[i][i]=1; ch[i][1] = i%1007; } for(i =2; I <= -; i++) for(j =2; J <= I; J + +) Ch[i][j]= (Ch[i-1][J]%1007+ Ch[i-1][j-1] %1007) %1007; intT; CIN>>T; while(t--) { intm, N; scanf ("%d%d", &m, &N); cout<< Ch[n][m] <<Endl; } return 0;}
View Code
HDU 1799 cycles How many times? Tips for solving problems