Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2073 Accepted Submission(s): 1046
#include <iostream> #include <cstdio> #define LL int using namespace std; void solve(LL x) { while((x%2)==0) { x/=2; if(x==1) break; } while((x%3)==0) { x/=3; if(x==1) break; } if(x==1) printf("YES!\n"); else printf("NO!\n"); } int main() { LL x,T; while(~scanf("%d",&x)) { if(x==1 || x==2) printf("YES!\n"); if(x==0) printf("NO!\n"); if(x!=1 && x!=2 && x!=0) solve(x+1); } return 0; }
原文:http://www.cnblogs.com/xianbin7/p/4530879.html