博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Self Numbers
阅读量:6555 次
发布时间:2019-06-24

本文共 1662 字,大约阅读时间需要 5 分钟。

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.

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 Output

135792031425364 | |       <-- a lot more numbers |9903991499259927993899499960997199829993
#include 
using namespace std;int a[10100];int p(int n){
int t; t=n; while(n!=0) {
t+=n%10; n=n/10; } return t;}int main(){
int i,j;memset(a,0,sizeof(a));for(i=1;i<10000;i++){
j=p(i);a[j]=1;}for(i=1;i<10000;i++)if(a[i]!=1)cout<
<
筛选法

转载于:https://www.cnblogs.com/lengxia/p/4387843.html

你可能感兴趣的文章
tag标签
查看>>
TTS语言 录音功能
查看>>
MySQL 查询最大最小值优化
查看>>
软件工程的实践项目课程的自我目标
查看>>
Weak is not weak,Strong is not strong
查看>>
setsockopt 详解
查看>>
首次使用AWS服务器EC2
查看>>
POJ-1860-Currency Exchange
查看>>
[深度学习]受限玻尔兹曼机生成手写数字训练样本原理
查看>>
莫比乌斯反演
查看>>
Django Hello World
查看>>
分析rails日志,计算响应率
查看>>
PHP 提交checkbox表单时 判断复选框是否被选中
查看>>
day12-sqlalchemy 常用语法
查看>>
Interval GCD CH4302
查看>>
Vim + SpaceVim强大的Linux系统下的编辑器
查看>>
dxRibbonRadialMenu控件使用
查看>>
知识总结:测试用例
查看>>
Xutils请求服务器json数据与下载文件
查看>>
2018 Wannafly summer camp Day2--Utawarerumono
查看>>