G - Self Numbers(2.2.1)

Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u

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

1
3
5
7
9
20
31
42
53
64
|
| <-- a lot more numbers
|
9903
9914
9925
9927
9938
9949
9960
9971
9982
9993
#include<iostream>
#include<cstring>
using namespace std;
int shzi(int k)
{
int s;
s=k;
while(s!=0)
{
k=k+s%10;
s=s/10;
} return k;} int a[10001],n=10000;
int main()
{
memset(a,0,sizeof(a));
int i,k;
for(i=1;i<=10000;i++)
{
k=shzi(i);
if(k<=10000)
a[k]=1; }
for(i=1;i<=10000;i++)
if(!a[i])
cout<<i<<endl; return 0;
}

G - Self Numbers(2.2.1)的更多相关文章

  1. 2017CCPC秦皇岛 G题Numbers&&ZOJ3987【大数】

    题意: 给出一个数n,现在要将它分为m个数,这m个数相加起来必须等于n,并且要使得这m个数的或值最小. 思路: 从二进制的角度分析,如果这m个数中有一个数某一位为1,那么最后或起来这一位肯定是为1的, ...

  2. 2017 CCPC秦皇岛 G题 Numbers

    DreamGrid has a nonnegative integer . He would like to divide  into nonnegative integers  and minimi ...

  3. theano学习

    import numpy import theano.tensor as T from theano import function x = T.dscalar('x') y = T.dscalar( ...

  4. Linq分组

    1.lin语句 int[] nums = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0, 3 }; DataTable table = new DataTable("Numb ...

  5. Wifite.py 修正版脚本代码

    Kali2.0系统自带的WiFite脚本代码中有几行错误,以下是修正后的代码: #!/usr/bin/python # -*- coding: utf-8 -*- """ ...

  6. Theano2.1.3-基础知识之更多的例子

    来自:http://deeplearning.net/software/theano/tutorial/examples.html More Examples 现在,是时候开始系统的熟悉theano的 ...

  7. [中英双语] 数学缩写列表 (List of mathematical abbreviations)

    List of mathematical abbreviations From Wikipedia, the free encyclopedia 数学缩写列表 维基百科,自由的百科全书 This ar ...

  8. Little Jumper---(三分)

    Description Little frog Georgie likes to jump. Recently he have discovered the new playground that s ...

  9. 101个LINQ示例,包含几乎全部操作

    Restriction Operators Where - Simple public void Linq1() { , , , , , , , , , }; var lowNums = from n ...

随机推荐

  1. c++,类的组合

    1. 在A类中以B类的对象作为成员变量,称为类的组合(composition). 可以先看看这篇文章理解组合的用处: C++中组合的使用 http://blog.csdn.net/jia_xiaoxi ...

  2. python成长之路——第四天

    内置函数: callable:查看对象是否能被调用(对象是函数的话能被调用) #callable def f1(): pass f2="a" print(callable(f1)) ...

  3. vim常用操作技巧与配置

    vi是linux与unix下的常用文本编辑器,其运行稳定,使用方便,本文将分两部分对其常用操作技巧和配置进行阐述,其中参考了网上的一些文章,对作者表示感谢 PART1 操作技巧 说明: 以下的例子中  ...

  4. Python基础2:反射、装饰器、JSON,接口

    一.反射 最近接触到python的反射机制,遂记录下来已巩固.但是,笔者也是粗略的使用了__import__, getattr()函数而已.目前,笔者的理解是,反射可以使用户通过自定义输入来导入响应的 ...

  5. x64栈结构

    A function's prolog is responsible for allocating stack space for local variables, saved registers, ...

  6. jQuery 遍历ul li 添加 移除

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. Java--日期的使用

    Date 类: 最基础的日期时间类,返回一个相对日期的毫秒数.精确到毫秒,但不支持日期的国际化和分时区显示. Calender类: 相对于Date更加强大的时间类,是抽象类,提供了常规的日期修改功能和 ...

  8. Python字典处理技巧

    从字典中取值(不想由于搜索的键不存在而异常) 解决方法: 使用字典的get方法 (get方法只读取字典的值而不会去修改字典) d={'key':'value'} print d.get('key',' ...

  9. SQL语言类

     SQL语分为四类:数据查询语言DQL,数据操纵语言DML. 数据定义语言DDL,数据控制语言DCL. 1 数据查询语言DQL 数据查询语言DQL基本结构是由SELECT子句.FROM子句,WHE ...

  10. 高级UIKit-04(NSUserDefaults、NSKeyedArchiver、对象归档方法)

    [day05_1_UserDefault]:判断应用程序是否是第一次运行 NSUserDefaults:用来保存应用程序的配置信息如:程序运行次数,用户登陆信息等. // 使用系统提供的NSUserD ...