⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pku1142.cpp

📁 这是ACM 方面的资料 是PKU的 北京大学的出来的
💻 CPP
字号:
#include <stdio.h>
#include <math.h>
#include <memory.h>
int Add(int x)
{
	int ans;
	ans = 0;
	while (x)
	{
		ans += x % 10;
		x /= 10;
	}
	return ans;
}

int isSmith(int x)
{
	int p[11], ct[11], pn, i, ans;
	int xx = x;
	memset(ct, 0, sizeof(ct));
	pn = 0;
	for (i = 2; i * i <= x; i++)
	{
		if (x % i == 0)
		{
			p[pn] = i;
			do
			{
				x /= i;
				ct[pn]++;
			}
			while (x % i == 0);
			pn++;
		}
	}
	if (x != 1)
	{
		p[pn] = x;
		ct[pn] = 1;
		pn++;
	}
	if (pn == 1 && ct[0] == 1)
	{
		return 0;
	}
	for (i = 0, ans = 0; i < pn; i++)
	{
		ans += ct[i] * Add(p[i]);
	}
	if (ans == Add(xx))
	{
		return 1;
	}
	return 0;
}

int main()
{
	int s;
	while (scanf("%d", &s) != -1 && s != 0)
	{
		do
		{
			s++;
		}
		while (!isSmith(s));
		printf("%d\n", s);
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -