|
|
back to boardAgain WA #3 Posted by fsb4000 29 Nov 2010 06:31 #include<iostream> #include<cstdlib> #include<cmath> using namespace std; int main(void){ long N; long *b; long i; long double m; cin>>N; b=new long[N]; for(i=0;i<N;i++){ cin>>b[i]; } for(i=0;i<N;i++){ m=(sqrt(long double(8.0*long double(b[i])-7.0))-1.0)/2.0; if(fabs(m-ceil(m))<0.0001) if(i!=N-1){cout<<"1"<<" ";} else{cout<<"1";} else if(i!=N-1)cout<<"0"<<" ";else{cout<<"0";} } cout<<endl; system("pause"); return 0; } Why WA#3? Re: Again WA #3 low accuary i think, work with integers numbers Re: Again WA #3 Posted by zAlogic 16 Dec 2010 15:30 in 3 test need use LONG... #include<iostream> #include<cstdlib> #include<cmath> using namespace std; int main(void){ long N; long *b; long i; long double m; cin>>N; b=new long[N]; for(i=0;i<N;i++){ cin>>b[i]; } for(i=0;i<N;i++){ m=(sqrt(long double(8.0*long double(b[i])-7.0))-1.0)/2.0; if(fabs(m-ceil(m))<0.0001) if(i!=N-1){cout<<"1"<<" ";} else{cout<<"1";} else if(i!=N-1)cout<<"0"<<" ";else{cout<<"0";} } cout<<endl; system("pause"); return 0; } Why WA#3? |
|
|