Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

菜鸟ACMer 99题纪念…水过…

Posted by LMagic at 2010-08-23 04:21:33 on Problem 1775
#include <iostream>
#include <cstdio>
using namespace std;

const int fac[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main()
{
    int N;
    while(cin>>N)
    {
       if(N<0)
          break;
       if(!N)
       {
          cout<<"NO"<<endl;
          continue;
       }
       for(int j=9;j>=0;j--)
       {
          if(fac[j]<=N)
             N-=fac[j];
       }
       if(!N)
          cout<<"YES"<<endl;
       else 
          cout<<"NO"<<endl;
    }
    return 0;
}


       

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator