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; int fact[10]; bool canbe[1000010]; void inti() { int i; fact[0]=1; for(i=1;i<10;i++) fact[i]=i*fact[i-1]; } int main() { inti(); memset(canbe,0,sizeof(canbe)); int a0,a1,a2,a3,a4,a5,a6,a7,a8,a9; for(a0=0;a0<=1;a0++) for(a1=0;a1<=1;a1++) for(a2=0;a2<=1;a2++) for(a3=0;a3<=1;a3++) for(a4=0;a4<=1;a4++) for(a5=0;a5<=1;a5++) for(a6=0;a6<=1;a6++) for(a7=0;a7<=1;a7++) for(a8=0;a8<=1;a8++) for(a9=0;a9<=1;a9++) { int t=a0*fact[0]+a1*fact[1]+a2*fact[2]+a3*fact[3]+ a4*fact[4]+a5*fact[5]+a6*fact[6]+a7*fact[7]+ a8*fact[8]+a9*fact[9]; if(t<=1000010&&t!=0) canbe[t]=true; } int n; while(scanf("%d",&n)!=EOF&&n>=0) { if(canbe[n]) 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