- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long int
- #define M 10056
- int DP[1005][1005];
- int dp[1005];
- int bc(int n, int k){
- int i, j;
- for (i = 0; i <= n; i++){
- for (j = 0; j <= k; j++){
- if (j == 0 || j == i)
- DP[i][j] = 1;
- else
- DP[i][j] = (DP[i-1][j-1]%M + DP[i-1][j]%M)%M;
- }
- }
- }
- int main(){
- bc(1000, 1000);
- dp[0] = dp[1] = 1;
- dp[2] = 3;
- for(int i = 3; i <= 1000; i++){
- for(int j = i-1; j>=0; j--){
- dp[i]+= (dp[j]%M)*(DP[i][i-j]%M)%M;
- dp[i]%=M;
- }
- }
- /*
- for(int i = 0; i <=1000; i++){
- for(int j = 0; j <=1000; j++){
- cout<<DP[i][j]<<" ";
- }
- cout<<endl;
- }
- */
- //int n;
- //scanf("%d", &n);
- //for(int i = 1; i<10; i++) cout<<dp[i]<<" ";
- int ts;
- scanf("%d", &ts);
- for(int i = 1; i <= ts; i++){
- int n;
- scanf("%d",&n);
- printf("Case %d: %d\n", i, dp[n]);
- }
- return 0;
- }
Saturday, 29 July 2017
Lightoj 1326 - Race
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
-
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
No comments:
Post a Comment