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 1665. Dean's Financial Pyramid

Could you tell me what's wrong with my program?(I got WA 2)
Posted by yuyan 14 Jan 2009 08:29
What's wrong with my program?Could you give me some test?
Thank you!
Sorry for my poor English!:)
Here is my program:
#include<iostream.h>
int main()
{
 freopen("financial.in","r",stdin);
 freopen("finiancial.out","w",stdout);
 int testcase;
 cin>>testcase;
 int i,m,n;
 bool flag;
 for (int t=1;t<=testcase;t++)
   {
    cin>>n;
    m=1;
    while (n%2==0)
      {
       n=n>>1;
       m+=1;
      }
    if ((m%2==1) && (n>1))
      cout<<"YES"<<endl;
    else {
          flag=false;
          for (i=2;i<=n-1;i++)
            if (n%i==0)
              {
               flag=true;
               break;
              }
          if (flag) cout<<"YES"<<endl; else cout<<"NO"<<endl;
         }
   }
 return 0;
}

Thank you for your help!
Re: Could you tell me what's wrong with my program?(I got WA 2)
Posted by Vadick 16 Jan 2009 18:11
try this test
1
8
the correct answer is YES, but your answer is NO
Re: Could you tell me what's wrong with my program?(I got WA 2)
Posted by yuyan 16 Jan 2009 19:07
Thanks for your help.
I got AC finally.