Title Description
Square theorem is known: an arbitrary positive integer n- n-, can be divided into no more than four and the square of an integer. For example: 25 = 1 + ^ 2 ^ {2} {2} {2} + ^ 2 + 4 ^ {2} 2 . 5 = 1 2 + 2 2 + 2 2 + 4 2, of course, other decomposition schemes, = 25 ^ 4 ^ {2} {2} 3 + 2 5 = 4 2 + 3 2 and 25 5 ^ {2} = 2 5 = 5 2. Given positive integer the n- the n-, programming statistics of the total number of programs it can break down. Note: 25 = 4 ^ 3 ^ {2} + {2} 2 . 5 = 4 2 + 3 2 and 25 = 3 ^ 4 ^ {2} + {2} 2 . 5 = 3 2+ 4 2 as a program.
Input Format
The first positive integer behavior T T ( T \ Le 100 T ≤ . 1 0 0), the next T T lines, each a positive integer n- n-( n-\ 32768 Le n- ≤ . 3 2 . 7 . 6 . 8).
Output Format
For each positive integers n- n-, the total number of output scheme.
Sample input and output
1 2003
48
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<queue> using namespace std; int f[32770][5]; int n=32768,t,ans; int main(){ scanf("%d",&t); f[0][0]=f[0][0]|1; for(int i=1;i*i<=n;i++){ for(int j=i*i;j<=n;j++){ for(int l=1;l<=4;l++){ f[j][l]+=f[j-i*i][l-1]; } } } while(t--){ ans=0; scanf("%d",&n); for(int i=1;i<=4;i++){ ans+=f[n][i]; } printf("%d\n",ans); } return 0; }