Title Description
The tetragonal theorem is well known: any positive integer NN can be decomposed into the sum of squares of no more than four integers.For example: 25=1^{2}+2^{2}+2^{2}+2^{2}+4^{2}25=12+22+42, and of course there are other decomposition schemes, 25=4^{2}+3^{2}25=42+32 and 25=5^{2}25=52.Given a positive integer nn, the program counts the total number of solutions it can decompose.Note: 25=4^{2}+3^{2}25=42+32 and 25=3^{2}+4^{2}25=32+42 are considered a scenario.
Input and Output Formats
Input format:
The first line is a positive integer t t (tle 100t < 100), and the next t t line is a positive integer n n (nle 768n < 32768) for each line.
Output format:
For each positive integer nn, the total number of output scenarios.
Input and Output Samples
1 2003
// luogu-judger-enable-o2 #include<iostream> #include<cstdio> #define LL long long using namespace std; const int MAXN=1e5+10; int dp[5][MAXN]; int main() { #ifdef WIN32 freopen("a.in","r",stdin); #else #endif dp[0][0]=1; for(register int i=1;i<=200;i++) for(register int j=1;j<=4;j++) for(register int k=1;k<=32768;k++) if(i*i<=k) dp[j][k]+=dp[j-1][k-i*i]; int T; scanf("%d",&T); while(T--) { int a; scanf("%d",&a); printf("%d\n",dp[1][a]+dp[2][a]+dp[3][a]+dp[4][a]); } return 0; }
// luogu-judger-enable-o2 #include<iostream> #include<cstdio> #define LL long long using namespace std; const int MAXN=1e6+10; int mul[MAXN],dp[MAXN]; int ans[MAXN]; int main() { #ifdef WIN32 freopen("a.in","r",stdin); #else #endif int N=200; for(int i=1;i<=N;i++) mul[i]=i*i; for(int i=1;i<=N;i++) ans[ mul[i] ] ++; for(int i=1;i<=N;i++) for(int j=i;j<=N;j++) ans[ mul[i]+mul[j] ] ++; for(int i=1;i<=N;i++) for(int j=i;j<=N;j++) for(int k=j;k<=N;k++) ans[ mul[i]+mul[j]+mul[k] ] ++; for(int i=1;i<=N;i++) for(int j=i;j<=N;j++) for(int k=j;k<=N;k++) for(int l=k;l<=N;l++) ans[ mul[i]+mul[j]+mul[k]+mul[l] ]++; int T; scanf("%d",&T); while(T--) { int a; scanf("%d",&a); printf("%d\n",ans[a]); } return 0; }