Self Numbers

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6960    Accepted Submission(s):
3047

Problem 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.

Write a
program to output all positive self-numbers less than or equal 1000000 in
increasing order, one per line.

 
Sample Output
1
3
5
7
9
20
31
42
53
64
|
| <-- a lot more numbers
|
9903
9914
9925
9927
9938
9949
9960
9971
9982
9993
|
|
|
 
Source
 
Recommend
Eddy   |   We have carefully selected several similar
problems for you:  1124 1157 1164 1113 1073 
 
这道题没有输入,看题目的意思写这个数组,直接筛选暴力打表就好。
 
题意:输出这一串数字,1000000以内所有的每个数,加上自身每一位数字,可以生产另一个数,但有些数,不能通过这样产生,请输出这些数。
 
附上代码:
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int visit[];
int xx(int n)
{
int sum=;
while(n!=)
{
sum+=n%;
n/=;
}
return sum;
}
int main()
{
int i,j,sum;
memset(visit,,sizeof(visit));
for(i=; i<=; i++) //直接暴力打表
{
sum=i;
sum+=xx(i);
visit[sum]=; //不需要出现的数字标记为0
}
for(i = ; i<=; i++)
{
if(visit[i])
printf("%d\n",i);
}
return ;
}

hdu 1128 Self Numbers的更多相关文章

  1. 【数位DP】 HDU 4722 Good Numbers

    原题直通车: HDU  4722  Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include& ...

  2. HDU 3117 Fibonacci Numbers(围绕四个租赁斐波那契,通过计++乘坐高速动力矩阵)

    HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意:  求第n个斐波那契数的 ...

  3. HDOJ(HDU).1058 Humble Numbers (DP)

    HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2 ...

  4. hdu 3117 Fibonacci Numbers 矩阵快速幂+公式

    斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...

  5. HDU 4722 Good Numbers

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 Good Numbers Time Limit: 2000/1000 MS (Java/Othe ...

  6. HDU 4320 Arcane Numbers 1 (数论)

    A - Arcane Numbers 1 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  7. HDU 1058 Humble Numbers(离线打表)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1058 解题报告:输入一个n,输出第n个质因子只有2,3,5,7的数. 用了离线打表,因为n最大只有58 ...

  8. hdu 3117 Fibonacci Numbers

    这道题其实也是水题来的,求Fibonacci数的前4位和后4位,在n==40这里分界开.后4位不难求,因为n达到了10^18的规模,所以只能用矩阵快速幂来求了,但在输出后4位的时候一定要注意前导0的处 ...

  9. HDU 1058 Humble Numbers (DP)

    Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

随机推荐

  1. string型的“600.000”如何转换为int型

    string型的“600.000”怎么转换为int型?为什么我用int.parse不能转换? ------解决方案--------------------int.Parse("600.000 ...

  2. 微信小程序制作选项卡

    wxml: <view class="tab"><view class="tab-title" bindtap="tabFun&qu ...

  3. C++ 之手写strcpy

    char *strcpy(char* strDest, const char*strSrc){ assert(strDest != NULL&&strSrc != NULL); cha ...

  4. JavaEE架构简介与JavaWeb新特性

    Fragment 将一个web应用做成几个部分,然后整合 创建Fragment项目   然后打包放入Servlet项目中的WEB-INF下的lib中 注解 @WebServlet @WebServle ...

  5. python中的open函数

    open函数用于文件处理 操作文件时,一般需要经历如下步骤: 打开文件 操作文件 一.打开文件 1 文件句柄 = open('文件路径', '模式') 打开文件时,需要指定文件路径和以何等方式打开文件 ...

  6. 异步操作async await

    async函数的特点: 语义化强 里面的await只能在async函数中使用 await后面的语句可以是promise对象.数字.字符串等 async函数返回的是一个Promsie对象 await语句 ...

  7. C++:参数

    一.基础 实参是形参的初始值,对每个形参都需要穿一个能转换为它的实参 形参列表中的形参通常用逗号隔开,其中每个形参都含有一个声明符的声明 二.main(int argc, char *argv[]) ...

  8. Directx11教程(5) 画一个简单的三角形(1)

    原文:Directx11教程(5) 画一个简单的三角形(1)       在本篇教程中,我们将通过D3D11画一个简单的三角形.在D3D11中,GPU的渲染主要通过shader来操作(当然还有一些操作 ...

  9. JavaScript--时间日期格式化封装

    这是一个正常的封装: 其他非正常的请按照以下语句自由搭配 <!DOCTYPE html> <html lang="en"> <head> < ...

  10. ELK4之进阶学习

    1.精确查找和模糊查找(term和match的区别) match经过分析(analyer)的, term是不经过分词,直接去倒排索引中查找精确的值. 2.建议器的简介(最左前缀或者自带的做) (1)直 ...