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

算是搜索题吧,先把所以yes的情况找出来

Posted by 1004115224 at 2012-08-18 12:45:26 on Problem 1775
#include<iostream>
#include<cstring>
using namespace std;
int a[12];
bool v[6000000];
int sum;
int go(int x)
{
    if(x==11)
    {
        v[sum]=1;
        return 0;
    }
    sum+=a[x];
    go(x+1);
    sum-=a[x];
    go(x+1);
    return 0;
}
int main()
{
    memset(v,0,sizeof(v));
    a[0]=1;
    for(int i=1;i<=10;i++)a[i]=a[i-1]*i;
    sum=0;
    go(0);
    int n;
    while(cin>>n)
    {
        if(n<0)return 0;
        if(v[n]==1&&n!=0)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