#include <iostream>
#include <cstdio>
#include <memory.h>
#include <algorithm>
#include <string>
using namespace std;
const int maxn=80;
int len=0;
char str[maxn];
string mul(string s,int n){
int carry=0;
for (int i=s.size()-1;i>=0;--i){
int t=s[i]-'0';
t=t*n+carry;
carry=t/10;
t=t%10;
s[i]='0'+t;
}
while (carry){
s.insert(s.begin(),(carry%10)+'0');
carry/=10;
}
return s;
}
int main(){
while (scanf("%s",str)==1){
int f1=1;
len=strlen(str);
for (int i=1;i<=len;++i){
string s=str;
string r=mul(str,i);
if(r.size()==s.size()){
int f2=0;
for (int i=0;i<r.size();++i){
if(s==r){
f2=1;
break;
}
rotate(r.begin(),r.begin()+1,r.end());
}
if(f2==0){
f1=0;
break;
}
}else{
f1=0;
break;
}
}
if(f1){
printf("%s is cyclic\n",str);
}else{
printf("%s is not cyclic\n",str);
}
}
return 0;
}
ZOJ 1073 Round and Round We Go(高精度乘法)
最新推荐文章于 2023-04-13 12:40:09 发布