|
|
back to boardwa test 3 Posted by Shohin 26 Nov 2013 20:49 #include <iostream> #include <math.h> using namespace std; int main() { double m,n; int a[70000],g; int N; cin>>N; for (int i=1; i<=N; i++) { cin>>m; n=(-1+sqrt(8*m+1))/2; if((n!=(int)n)){ g=n; g++; } else { g=n; } g--; int k=((1+g)*g)/2; if(m-k==1) a[i]=1; else a[i]=0; } for(int i=1;i<=N;i++) cout<<a[i]<<" "; system("pause"); return 0; } Edited by author 26.11.2013 20:50 Re: wa test 3 Change your data range. try unsigned long long int, long . I had faced same problem. Re: wa test 3 Thanks rakibdana.. |
|
|