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(n),没道理#include <stdio.h> int main() { int i,q,r,n; bool yes; while(true) { yes = true; scanf("%d",&n); if(n<0) break; q = n; for(i=2;i<=n-1;i++) { r = q%i;// printf("%d\n",r); if(r!=1 && r!=0) { yes =false; break; } q = q / i; } if(yes && (q==1||q==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