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

wa 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
Posted by rakibdana 20 May 2014 12:04
Change your data range. try unsigned long long int, long . I had faced same problem.
Re: wa test 3
Posted by Sanatbek_Matlatipov 12 Sep 2015 14:20
Thanks rakibdana..