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 |
O(9)的贪心还要32ms,这是为什么?#include<stdio.h> int fac[10]={1,1,2,6,24,120,720,5040,40320,362880}; int main() { int n,i,sign; while(scanf("%d",&n),n>=0) { sign=0; for(i=9;i>=0;i--) { if(n>=fac[i]) { n-=fac[i]; sign=1; } } if(sign && !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