定义一种数位simth数,该数的各位之和等于其所有质因子所有位数字之和,现给出n求大于n的最小该种数,n最大不超过8位,那么直接暴力就可以了。

/** @Date    : 2017-09-08 14:12:08
* @FileName: HDU 1333 素因子 暴力.cpp
* @Platform: Windows
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version : $Id$
*/
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; LL pri[N];
LL sum[N];
bool vis[N];
int c = 0;
void prime()
{
MMF(vis);
MMF(sum);
for(int i = 2; i < N; i++)
{
if(!vis[i])
{
pri[c++] = i;
LL t = i;
while(t)
sum[c - 1] += t % 10, t /= 10;
}
for(int j = 0; j < c && i * pri[j] < N; j++)
{
vis[i * pri[j]] = 1;
if(i % pri[j] == 0) break;
}
}
} int main()
{
prime();
LL n;
while(cin >> n && n)
{
for(int i = n + 1; ;i++)
{
LL tmp = i;
LL a = 0;
while(tmp)
a += tmp % 10, tmp /= 10; LL b = 0;
LL t = i;
for(int j = 0; j < c && pri[j] * pri[j] <= t; j++)
{
if(t % pri[j] == 0)
{
while(t % pri[j] == 0)
t /= pri[j], b+=sum[j];
}
}
if(t != i && t > 1)
while(t)
b += t % 10, t/= 10;
if(b == a)
{
printf("%lld\n", i);
break;
}
}
}
return 0;
}

最新文章

  1. iterm2
  2. Asp.net Mvc Entity Framework Code First 数据库迁移
  3. Unity扩展编辑器学习笔记--从路径下找到拥有某个组件类型的预设
  4. Struts2:类型转换器
  5. Oracle Created (Default) Database Users
  6. [Outlook] outlook如何实现自动CC和BCC邮件发送
  7. [SAP ABAP开发技术总结]Function远程、同步、异步调用
  8. Runtime机制之结构体及操作函数
  9. Keep the Customer Satisfied
  10. [codevs1073]家族
  11. poj 1050 To the Max (简单dp)
  12. html/css获得第一章
  13. 用python 爬取网页图片
  14. UIRoot
  15. ubuntu更换内核版本
  16. 编写高质量代码改善程序的157个建议:使用Dynamic来简化反射的实现
  17. Cloud Carousel
  18. 远程连接MySQL(MariaDB)数据库
  19. Mysql 操作技巧
  20. &lt;HTML深入浅出&gt; 读书笔记

热门文章

  1. Beta发布-----欢迎来怼团队
  2. HDU 5501 The Highest Mark
  3. WPF和Expression Blend开发实例:充分利用Blend实现一个探照灯的效果
  4. Struts2(七)
  5. spring表单—乱码解决方案
  6. 在线webservice
  7. ADO之connection
  8. PHP中is_null()方法
  9. SQL中的declare用法
  10. SolrPerformanceFactors--官方文档