POJ 1316 Self Numbers 筛选模拟
来源:互联网 发布:php网页聊天室原理 编辑:程序博客网 时间:2024/06/05 05:52
Self Numbers
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 22203 Accepted: 12494
Description
In 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the digits of n. (The d stands for digitadition, a term coined by Kaprekar.) For example, d(75) = 75 + 7 + 5 = 87. Given any positive integer n as a starting point, you can construct the infinite increasing sequence of integers n, d(n), d(d(n)), d(d(d(n))), .... For example, if you start with 33, the next number is 33 + 3 + 3 = 39, the next is 39 + 3 + 9 = 51, the next is 51 + 5 + 1 = 57, and so you generate the sequence
33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, ...
The number n is called a generator of d(n). In the sequence above, 33 is a generator of 39, 39 is a generator of 51, 51 is a generator of 57, and so on. Some numbers have more than one generator: for example, 101 has two generators, 91 and 100. A number with no generators is a self-number. There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.
33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, ...
The number n is called a generator of d(n). In the sequence above, 33 is a generator of 39, 39 is a generator of 51, 51 is a generator of 57, and so on. Some numbers have more than one generator: for example, 101 has two generators, 91 and 100. A number with no generators is a self-number. There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.
Input
No input for this problem.
Output
Write a program to output all positive self-numbers less than 10000 in increasing order, one per line.
Sample Input
Sample Output
135792031425364 | | <-- a lot more numbers |9903991499259927993899499960997199829993
Source
Mid-Central USA 1998
AC代码:#include <iostream>#include <cmath>#include <cstring>#include <algorithm>using namespace std;int main(){ int i,j,k,m,n; int a[10050]; memset(a,1,sizeof(a)); for(i=0;i<10;i++)for(j=0;j<10;j++)for(m=0;m<10;m++)for(n=0;n<10;n++) a[1001*i+101*j+11*m+2*n]=0; for(i=0;i<=10000;++i) if(a[i])cout<<i<<'\12'; return 0;}
0 0
- POJ 1316 Self Numbers 筛选模拟
- (简单模拟——筛选法模拟2.2.1)POJ 1316 Self Numbers(生成数、自数)
- POJ 1316 Self Numbers
- POJ 1316 Self Numbers
- poj 1316 Self Numbers
- POJ 1316 Self Numbers
- POJ 1316 Self Numbers
- poj 1316 Self Numbers
- POJ 1316 Self Numbers
- POJ 1316 Self Numbers
- Self Numbers (poj 1316)
- POJ 1316 Self Numbers
- POJ 1316 Self Numbers
- Self Numbers(POJ--1316
- Self Numbers POJ 1316
- poj 1316 Self Numbers
- Poj 1316 Self Numbers(水题)
- Self Numbers - POJ 1316 水题
- Windows下命令安装MySQL.zip压缩包以及修改MySQL密码
- swirl 6: Subsetting Vectors
- sendmail 发送html 的邮件
- hdu5277 YJC counts stars(最大团)
- [LeetCode]Contains Duplicate II
- POJ 1316 Self Numbers 筛选模拟
- Intellij--File Status Highlights文件高亮规则
- Android学习日志: 执行.getResponseCode()方法时出现错误常
- HMM隐马尔可夫
- 快速幂模板
- HDU 2700 Parity
- 12.1 Image classification with deep learning常用模型
- 四大组件之Activity小结
- jsoncpp详解