POJ 1047
#include <iostream> #define MAXN 100 using namespace std; char _m[MAXN]; int ans[MAXN]; int main() { //freopen("acm.acm","r",stdin); int len; int i; int mul; int c; while(cin>>_m) { memset(ans,0,sizeof(ans) ); // cout<<_m<<endl; len = strlen(_m); mul = len+1; for(i = 0; i < len; ++ i) { ans[len-1-i] = (_m[i]-'0')*mul; } c = 0; for(i = 0; i < MAXN; ++ i) { ans[i] += c; c = ans[i] / 10; ans[i] %= 10; } bool boo = false; for(i = MAXN-1; i >= 0; -- i) { // cout<<" *********8 "<<endl; if(ans[i] != 0 && !boo) { boo = true; } if(boo) { if(ans[i] != 9) { break; } } } if(i == -1) { cout<<_m<<" is cyclic"<<endl; } else { cout<<_m<<" is not cyclic"<<endl; } // cout<<endl; } }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com