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...

Test 1 help please.
Posted by freelife 3 Feb 2013 23:25
Hi! Please help russian shoolboy
Where the error is?
I realized that '1'-s are in the field of the sequence.
1 2 4 7 11 16
int main()
{
    long a,j,i,n;
    cin>>n;
    for(int x=0; x<n; x++)
    {
        cin>>a;
        i=1;
        j=1;
        while (a>i)
        {
           i=i+j;
           j++;
        }
        if (a==i)
            cout<<1;
        else
            cout<<0;
     }
    return 0;
}
Re: Test 1 help please.
Posted by Dima 5 Mar 2013 01:54
while (a>i)
        {
           i=i+j;
           j++;
        }