//大数相乘!注意最后一位是否有进位!
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int ans[100];
int main()
{
string str;
int input[70], tmp[70];
int i, j, k, len;
bool flag1;
while (cin >> str)
{
len = str.length();
flag1 = false;
for (i = len-1, j = 0; i >= 0; i--, j++)
{
input[j] = str[i] - 48;
tmp[j] = input[j];
}
sort(tmp, tmp+j);
for (i = 1; i <= len; i++)
{
if (flag1) break;
memset(ans, 0, sizeof(ans));
for (j = 0; j < len; j++)
{
ans[j] += input[j]*i;
if (ans[j] >= 10)
{
ans[j+1] += ans[j]/10;
ans[j] %= 10;
}
}
if (ans[j] >= 10)
{
ans[j+1] += ans[j]/10;
ans[j] %= 10;
j++;
}
sort(ans, ans+j);
for (k = 0; k < j; k++)
{
if (tmp[k] != ans[k])
{
flag1 = true;
break;
}
}
if (flag1) break;
}
if (flag1)
cout << str << " is not cyclic" << endl;
else
cout << str << " is cyclic" << endl;
}
system("pause");
}
poj 1047 Round and Round We Go
最新推荐文章于 2019-08-07 16:40:40 发布