水题,直接贴代码。
//poj 1959
//sep9
#include <iostream>
using namespace std;
int n;
int f[128];
int solve()
{int x,y,z,sum=0;for(x=0;x<=n&&x<=60;++x)for(y=x;y<=n&&y<=60;++y)for(z=y;z<=n&&z<=60;++z)if(x+y+z==n){if(x==y&&y==z){int m=f[x];sum+=(m+2)*(m+1)*m/6; } else if(x==y||y==z){int m,c;if(x==y){m=f[x];c=f[z];}else{m=f[y];c=f[x];}sum+=((m+1)*m/2)*c;}else sum+=f[x]*f[y]*f[z];} return sum;
}int main()
{int cases,t=0;memset(f,0,sizeof(f));f[0]=1;for(int i=1;i<=3;++i)for(int j=1;j<=20;++j)++f[i*j];++f[25];++f[50];scanf("%d",&cases);while(cases--){scanf("%d",&n);printf("Scenario #%d:\n%d\n\n",++t,solve());}return 0;
}