1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #include <bits/stdc++.h> #define N 64000 #define mod 1000000007 #define FOR(i,n) for(int i=0;i<n;i++) #define ios ios::sync_with_stdio(0) using namespace std; int num[5],sqr[N]; int solution = 0,n;
void init(){ for(int i=0;i<N;i++)sqr[i] = i*i; }
void pick(int remain,int id){ if(id==4){ int r = sqrt(remain); if(sqr[r]==remain){ cout<<num[1]<<" "<<num[2]<<" "<<num[3]<<" "<<r<<endl; solution++; } return; } int lower = max(1,num[id-1]),upper = sqrt(remain/(5-id)); for(int i=lower;i<=upper;i++){ num[id]= i; pick(remain-sqr[i],id+1); } }
signed main(){ ios; init(); cin>>n; pick(1<<n,1); if(solution==0)cout<<0<<endl; }
|