How many times are the loops?
Time limit:3000/1000 MS (java/others) Memory limit:65536/32768 K (java/others) total submission (s): 3096 Accepted Submission (s): 1144
Problem 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 a for (i=1;i<=n;i++) OP appears in the code; Then do N-Times op, 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 has T group case,t<=10000. Each case has two integers m and n,0<m<=2000,0<n<=2000.
Output for each case, outputs a value that represents the total amount of computation, perhaps a large number, then you only need to output the remainder of the 1007 left.
Sample Input21 32 3
Sample Output33ps:c (N) (m) =c (n-1) (m) +c (n-1) (m-1);#include "stdio.h"
int c[2005][2005];
int main ()
{
int n,m,t;
C[0][0]=1;
for (n=1;n<=2000;n++)
{
C[n][0]=1;
for (m=1;m<=2000;m++)
C[n][m] = (C[n-1][m] + c[n-1][m-1])% 1007;
}
scanf ("%d", &t);
while (t--)
{
scanf ("%d%d", &m,&n);
printf ("%d\n", C[n][m]);
}
return 0;
}
Hdu 1799 has a formula: Never taught. C (n) (m) =c (n-1) (m) +c (n-1) (m-1)