| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
其实这样就可以了。#include<iostream>
using namespace std;
const int s[10]={1,1,2,6,24,120,720,5040,40320,362880};
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n<0)
break;
else if(n==0)
{
printf("NO\n");
}
else
{
for(int i=9;i>=0;i--)
{
if(n>=s[i])
n=n-s[i];
}
if(n==0)
printf("YES\n");
else
printf("NO\n");
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator