Pages

Tuesday 13 January 2015

spoj solution of Beehive Numbers problem BEENUMS

solution of Beehive Numbers problem 


#include<iostream>
using namespace std;
int main()
{
long long int n,s,i;
while(1)
{
cin>>n;
if(n==-1)
break;
else
{
 i=0;s=1;
 while(1)
 {
  s=s+6*i;
  if(s>n)
  {
  cout<<"N"<<endl;
  break;
  }
  else if(s==n)
  {
  cout<<"Y"<<endl;
  break;
 
  }
  else
  i=i+1;
 }
}
}
return 0;

}

No comments:

Post a Comment