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 |
一遍过讨论所有数据无改动1A并表示不会数学 高精乱搞ORZ XLK WZC1995 LYDLIYUDONG #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; char s[1000]; int b[1000], a[1000], len; inline void times(int x) { for(int i = 1; i <= len; i ++) b[i] = 0; for(int i = len; i >= 1; i --) { b[i] += a[i] * x; b[i - 1] = b[i] / 10; b[i] %= 10; } for(int i = 1; i <= len; i ++) b[i + len] = b[i]; } inline bool check() { bool is_finish; for(int i = 1; i <= len; i ++) { is_finish = true; for(int j = 0; j < len; j ++) if(a[j + 1] != b[i + j]) {is_finish = false; break;} if(is_finish) break; } if(is_finish == false) return false; else return true; } int main() { while(scanf("%s", s + 1) != EOF) { len = strlen(s + 1); for(int i = 1; i <= len; i ++) a[i] = s[i] - '0'; bool ans = true; for(int i = 1; i <= len; i ++) { times(i); if(check() == false) { ans = false; break; } } if(ans) printf("%s is cyclic\n", s + 1); else printf("%s is not cyclic\n", s + 1); } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator