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

其实这样就可以了。

Posted by tanjing at 2010-10-06 15:00:00 on Problem 1775
#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:
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