一、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. information entropy as a measure of the uncertainty in a message while essentially inventing the field of information theory

    https://en.wikipedia.org/wiki/Claude_Shannon In 1948, the promised memorandum appeared as "A Ma ...

  2. saltStack 证书管理

    SaltStack 使用 SSL 签证的方式进行安全认证,我们可以在 Master 端看到 Minion 端的整数签证请求 1.查看当前证书签证情况 [root@SaltStack-Master ~] ...

  3. python+NLTK 自然语言学习处理七:N-gram标注

    在上一章中介绍了用pos_tag进行词性标注.这一章将要介绍专门的标注器. 首先来看一元标注器,一元标注器利用一种简单的统计算法,对每个标识符分配最有可能的标记,建立一元标注器的技术称为训练. fro ...

  4. Redis持久化——多实例部署(四)

    Redis单线程架构导致无法充分利用CPU特性,通常的做法是在一台机器上部署多个实例. 当多个实例开启AOF重写后,彼此之间会产生对CPU和IO的竞争. 对于单机部署多Redis部署,如果同一时刻运作 ...

  5. 基于CocoaPods的iOS项目模块化实践

    什么是CocoaPods? CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has ove ...

  6. ssl和tls

    HTTP 是一个网络协议,是专门用来帮你传输 Web 内容 SSL 是Secure Sockets Layer 为啥要发明 SSL 这个协议捏?因为原先互联网上使用的 HTTP 协议是明文的,存在很多 ...

  7. 【leetcode刷题笔记】Scramble String

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  8. hd acm1466

    http://www.cnblogs.com/alihenaixiao/p/4107907.html#undefined.这个博客有详解,我这个只是写一些·自己的总结. 问题:平面上有n条直线,且无三 ...

  9. Hive报错 Failed with exception java.io.IOException:java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:user.name%7D

    报错信息如下 Failed with exception java.io.IOException:java.lang.IllegalArgumentException: java.net.URISyn ...

  10. tkinter窗口系列之一——列表框

    以下内容来自https://tkdocs.com/tutorial/morewidgets.html 一个列表框显示由单行文本所组成的一栏条目,通常它很冗长,它允许使用者通过列表浏览其中的内容,选择一 ...