一、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.

二、题解

        只做学习记录!

三、Java代码

public class Main {

    public static void main(String[] args) { 

    	boolean flag[]=new boolean[10001];
int t;
for(int i=1;i<10000;i++){
t=i+i/1000+(i % 1000)/100+(i % 100)/10+i % 10;
if(t>10000)
continue;
flag[t]=true;
}
for(int i=1;i<10000;i++){
if(flag[i]==false)
System.out.println(i);
}
}
}

Poj 1316 Self Numbers(水题)的更多相关文章

  1. POJ 1488 Tex Quotes --- 水题

    POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...

  2. poj 1002:487-3279(水题,提高题 / hash)

    487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 236746   Accepted: 41288 Descr ...

  3. VK Cup 2016 - Qualification Round 2 A. Home Numbers 水题

    A. Home Numbers 题目连接: http://www.codeforces.com/contest/638/problem/A Description The main street of ...

  4. poj 2105 IP Address(水题)

    一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...

  5. POJ 3641 Oulipo KMP 水题

    http://poj.org/problem?id=3461 直接KMP就好.水题 #include<cstdio> #include<cstring> const int M ...

  6. poj 1006:Biorhythms(水题,经典题,中国剩余定理)

    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 110991   Accepted: 34541 Des ...

  7. poj 1003:Hangover(水题,数学模拟)

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 99450   Accepted: 48213 Descri ...

  8. poj 2000 Gold Coins(水题)

    一.Description The king pays his loyal knight in gold coins. On the first day of his service, the kni ...

  9. POJ 1504 Adding Reversed Numbers (水题,高精度整数加法)

    题意:给两个整数,求这两个数的反向数的和的反向数,和的末尾若为0,反向后则舍去即可.即若1200,反向数为21.题目给出的数据的末尾不会出现0,但是他们的和的末尾可能会出现0. #include &l ...

随机推荐

  1. rm -rf 删除文件找回

    一个不小心rm掉文件了吧? 后悔莫及了吧! 把这段代码加入你的home目录的.bashrc或者.zshrc就可以了! 工作原理: 在你的home目录会创建一个.trash文件夹 里面会按照删除时间 年 ...

  2. 【ELK】抓取AWS-ELB日志的logstash配置文件

    前言 ELK搭建没有难度,难的是logstash的配置文件,logstash主要分为三个部分,input,filter和output. input,输入源可选的输入源由很多,详情见ELK官网,这里我们 ...

  3. python元组和列表区别

    元组可以简单认为是一个只读的列表 tuper = const list

  4. 通过GPRS将GPS数据上传到OneNet流程

    AT OK AT+CGCLASS="B" OK AT+CGDCONT=1,"IP","CMNET" OK AT+CGATT=1 OK AT+ ...

  5. MVC中不能使用ViewBag

    在工程文件中添加 <Reference Include="Microsoft.CSharp" /> <Reference Include="System ...

  6. ELKK 日志处理

    http://blog.csdn.net/u010022051/article/details/54342357 在ELKK的架构中,各个框架的角色分工如下: ElasticSearch1.7.2:数 ...

  7. Effective java -- 7 通用程序设计

    第四十五条:将局部变量的作用域最小化 第四十六条:加强版for循环优于传统for循环 第四十七条:了解和使用类库书中提到了一个生成随机数的例子.正好需要. public static void mai ...

  8. Java多线程系列 JUC锁08 LockSupport

    转载 http://www.cnblogs.com/skywang12345/p/3505784.html https://www.cnblogs.com/leesf456/p/5347293.htm ...

  9. linux操作系统使用中的一些总结

    VIM常用命令 gg   //到第一行 (N)G   //到第n行(N为整数) G    //到最后一行 0    //到行头 $  //到行尾 (N)dd  //删除N行,并将内容保存到粘贴板 p ...

  10. P4388 付公主的矩形(gcd+欧拉函数)

    P4388 付公主的矩形 前置芝士 \(gcd\)与欧拉函数 要求对其应用于性质比较熟,否则建议左转百度 思路 有\(n×m\)的矩阵,题目要求对角线经过的格子有\(N\)个, 设函数\(f(x,y) ...