ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1209. 1, 10, 100, 1000...

Again 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
Posted by waterlink 15 Dec 2010 17:44
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...
fsb4000 wrote 29 November 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?