Created
May 5, 2015 11:13
-
-
Save lackofdream/7595d1a5567b073a2dcd to your computer and use it in GitHub Desktop.
HDU2566
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdio> | |
| #include <iostream> | |
| #include <cmath> | |
| #include <cstring> | |
| #include <cctype> | |
| #include <algorithm> | |
| #define sd(a) scanf("%d",&a) | |
| #define sdd(a,b) scanf("%d%d",&a,&b) | |
| #define abs(x) (x>0?x:(0-x)) | |
| #define MAX(a,b) (a>b?a:b) | |
| #define MIN(a,b) (a<b?a:b) | |
| using namespace std; | |
| int a1[100][100]; | |
| int a2[100][100]; | |
| int val[]={0,1,2,5}; | |
| void init(int n) | |
| { | |
| memset(a1,0,sizeof(a1)); | |
| memset(a2,0,sizeof(a2)); | |
| for(int i=0;i<=n;i++) | |
| { | |
| a1[i][i]=1; | |
| } | |
| } | |
| int main() | |
| { | |
| int t;sd(t); | |
| while(t--) | |
| { | |
| int n,m; | |
| sdd(n,m); | |
| init(n); | |
| for (int i=2;i<=3;i++) | |
| { | |
| for (int j=0;j<=m;j++) | |
| { | |
| for (int k=0;k+j<=m;k+=val[i]) | |
| { | |
| for (int l=0;l+k/val[i]<=n;l++) | |
| { | |
| a2[k+j][l+k/val[i]] += a1[j][l]; | |
| } | |
| } | |
| } | |
| for (int j=0;j<=m;j++) | |
| { | |
| for (int k=0;k<=n;k++) | |
| { | |
| a1[j][k]=a2[j][k]; | |
| a2[j][k]=0; | |
| } | |
| } | |
| } | |
| cout << a1[m][n] << endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment