有人能帮我看看吗,我全WA了
查看原帖
有人能帮我看看吗,我全WA了
424241
liujiafang楼主2022/8/19 11:33
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
int a[15],t[15],answer[15];
int e[10];
int itoz(LL x)
{
	memset(a,0,sizeof(a));
	memset(t,0,sizeof(t));
	memset(answer,0,sizeof(answer));
	memset(e,0,sizeof(e));
	int cur = 0;
	while (x != 0)
	{
		cur++;
		t[cur] = x % 10;
		if (x % 10 == 0) return -1;
		x /= 10;
	}
	for (int i = cur;i >= 1;i--) a[cur-i+1] = t[i];
	for (int i = 1;i <= cur;i++) e[a[i]]++;
	for (int i = 0;i <= 9;i++) if (e[i] > 1) return -1;
	return cur;
}
bool isxun(LL size)
{
	for (int i = 1;i <= size;i++)
	{
		int j = 1,w = 0;
		while (j <= a[i])
		{
			j++;
			w++;
			w = (w - 1) % size + 1;
		}
		answer[i] = w;
	}
	for (int i = 1;i <= size;i++) if (a[i] != answer[i]) return false;
	return true;
}
int main()
{
	LL n;
	cin >> n;
	while (true)
	{
		n++;
		int s = itoz(n);//int to 数组
		if (s == -1 || s > 10) continue;
		if (isxun(s))//是否是循环数
		{
			cout << n << endl;
			return 0;
		}
	}
	return 0;
}
小猴编程(7518098414547896
2022/8/19 11:33
加载中...