G - Self Numbers(2.2.1)
Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u
Description
= 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
Output
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)的更多相关文章
- 2017CCPC秦皇岛 G题Numbers&&ZOJ3987【大数】
题意: 给出一个数n,现在要将它分为m个数,这m个数相加起来必须等于n,并且要使得这m个数的或值最小. 思路: 从二进制的角度分析,如果这m个数中有一个数某一位为1,那么最后或起来这一位肯定是为1的, ...
- 2017 CCPC秦皇岛 G题 Numbers
DreamGrid has a nonnegative integer . He would like to divide into nonnegative integers and minimi ...
- theano学习
import numpy import theano.tensor as T from theano import function x = T.dscalar('x') y = T.dscalar( ...
- Linq分组
1.lin语句 int[] nums = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0, 3 }; DataTable table = new DataTable("Numb ...
- Wifite.py 修正版脚本代码
Kali2.0系统自带的WiFite脚本代码中有几行错误,以下是修正后的代码: #!/usr/bin/python # -*- coding: utf-8 -*- """ ...
- Theano2.1.3-基础知识之更多的例子
来自:http://deeplearning.net/software/theano/tutorial/examples.html More Examples 现在,是时候开始系统的熟悉theano的 ...
- [中英双语] 数学缩写列表 (List of mathematical abbreviations)
List of mathematical abbreviations From Wikipedia, the free encyclopedia 数学缩写列表 维基百科,自由的百科全书 This ar ...
- Little Jumper---(三分)
Description Little frog Georgie likes to jump. Recently he have discovered the new playground that s ...
- 101个LINQ示例,包含几乎全部操作
Restriction Operators Where - Simple public void Linq1() { , , , , , , , , , }; var lowNums = from n ...
随机推荐
- 浅析C++基础知识
近期想对C++的面试题目进行一下更加详细的整理.事实上认真思考一下C++程序猿的面试,我们能够发现对程序猿的能力的考察总是万变不离当中,这些基础知识主要分为五部分:一. C/C++基础知识 二. C/ ...
- MDK常见错误详解集合
错误代码及错误信息 错误释义 error 1: Out of memory 内存溢出 error 2: Identifier expected 缺标识符 error 3: Unknown identi ...
- CoinChange
题目 题目:CoinChange 有面额不等的coins,数量无限,要求以最少的\(coins\)凑齐所需要的\(amount\). 若能,返回所需的最少coins的数量,若不能,返回-1. Exam ...
- linux下安装greenplum
1. 下载 Greenplum Database 源代码 $ git clone https://github.com/greenplum-db/gpdb 2. 安装依赖库 Greenplum Dat ...
- Read and Write NSArray, NSDictionary and NSSet to a File
查询地址:http://iosdevelopertips.com/data-file-management/read-and-write-nsarray-nsdictionary-and-nsset- ...
- pycharm+QT4的helloworld
# -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 exc ...
- 笔记之Cyclone IV 第一卷第二章Cyclone IV器件的逻辑单元和逻辑阵
逻辑单元 (LE) 在 Cyclone IV 器件结构中是最小的逻辑单位.LE 紧密且有效的提供了高级功能的逻辑使用.每个 LE 有以下特性 ■ 一个四口输入的查找表 (LUT),以实现四种变量的任何 ...
- Dockerfile指令总结
指令的一般格式为INSTRUCTION arguments,指令包含FROM.MAINTAINER.RUN等. FROM 格式为FROM <image>或FROM <image> ...
- linux学习过程中所需要看的一些书籍
入门类 一直认为,在一个系统上学习开发之前,首先需要熟悉这个系统的使用.鉴于天朝的国情,绝大部分人第一个接触的操作系统就是Windows,因此对于这绝大部分人来说,如果要学习Linux开发,学会使用这 ...
- windows下apache如何完整卸载?
1.运行services.msc,在服务中停止 apache 服务.2.运行命令行程序,输入 sc delete apache,删除该服务3.删除apache文件夹.