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 |
全是洞也可以过啊。。。【附代妈】//============================================================================ // Name : main1047.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> #include <string> using namespace std; int main() { string s; while(getline(cin, s)){ int len = s.length(); int *org = new int[len]; for(int i = 0; i < len; i++){ org[i] = s[len - 1 - i] - '0'; } bool cyc = true; for(int i = 2; i <= len; i++){ int *res = new int[len]; for(int j = 0; j < len; j++){ res[j] = org[j] * i; } for(int j = 0; j < len-1; j++){ res[j+1] += res[j]/10; res[j] %= 10; } if(res[len-1] > 9){ cyc = false; break; } cyc = false; int o = 0; for(; o < len; o++){ int s = 0; for(; s < len; s++){ if(org[s] != res[(s+o)%len]){ break; } } if(s == len){ cyc = true; break; } } if(!cyc) break; delete [] res; } if(!cyc){ cout << s << " is not cyclic" << endl; } else{ cout << s << " is cyclic" << endl; } delete [] org; } //cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator