ACM Self Number
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 Input
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
题解:
基础题。题目不难,只要能够理解题意的话就能够顺利的做出来了.
代码:
/*
Name: Self Number
Copyright:
Author:
Date: 11/08/17 04:23
Description:
*/
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int NUM = ;
int record[NUM];
int judge(int i)
{
int temp = i;
while(i)
{
temp += i%;
i /= ;
}
return temp; /*返回非self number*/
} int main()
{
memset(record,,sizeof(record)); /*数组初始化,是一个好习惯*/
for(int i = ; i < NUM;i++)
{
int temp = judge(i);
if(temp < NUM )
record[temp] = ; /*将不是self number的整数标记为1*/
}
bool flag = false;
for(int i = ; i < NUM;i++)
{ if(record[i] == )/*注意输出格式 最后一个不空行*/
{
if(flag)
cout<<endl;
cout<<i;
flag = true;
} }
return ;
}
ACM Self Number的更多相关文章
- 第一届山东省ACM——Phone Number(java)
Description We know that if a phone number A is another phone number B’s prefix, B is not able to be ...
- [ACM_搜索] POJ 1096 Space Station Shielding (搜索 + 洪泛算法Flood_Fill)
Description Roger Wilco is in charge of the design of a low orbiting space station for the planet Ma ...
- Balanced and stabilized quicksort method
The improved Quicksort method of the present invention utilizes two pointers initialized at opposite ...
- Mine Number(搜索,暴力) ACM省赛第三届 G
Mine Number Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Every one once played the gam ...
- ACM—Number Sequence(HDOJ1005)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 主要内容: A number sequence is defined as follows: f ...
- [2013山东ACM]省赛 The number of steps (可能DP,数学期望)
The number of steps nid=24#time" style="padding-bottom:0px; margin:0px; padding-left:0px; ...
- ACM解题之在线翻译 Give Me the Number
Give Me the Number Time Limit: 2 Seconds Memory Limit: 65536 KB ...
- ACM HDU 1755 -- A Number Puzzle
A Number Puzzle Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- [2012山东省第三届ACM大学生程序设计竞赛]——Mine Number
Mine Number 题目:http://acm.sdut.edu.cn/sdutoj/problem.php? action=showproblem&problemid=2410 Time ...
随机推荐
- hadoop fs:du统计hdfs文件(目录下文件)大小的用法
hadoop fs 更多用法,请参考官网:http://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html 以下是我的使用统计文件时使用的记录: [t@d ...
- Hibernate(七):*.hbm.xml配置文件中Set三个属性
背景: 在上一篇文章中实现双向关联时,其中在Customer.java中我们使用了java.util.List<Order>来关联多的Order.其实还有另外一种实现方法:使用java.u ...
- QT 设计师使用样式表添加背景
QT create中样式表可以用来设置背景图.背景颜色.字体大小格式颜色等 1.添加背景图的话需要先添加资源文件 右击项目文件选择添加新文件,再选择QT资源文件(QT resource file)然后 ...
- JavaScript中内存使用规则--堆和栈
堆和栈都是运行时内存中分配的一个数据区,因此也被称为堆区和栈区,但二者存储的数据类型和处理速度不同.堆(heap)用于复杂数据类型(引用类型)分配空间,例如数组对象.object对象:它是运行时动态分 ...
- java.lang.Class类
第一次接触Class类是在学习 jdbc中.Class.forName()是Class类的一个静态方法,用于手动加载一个类,例如数据库驱动. 其实每一个java类都拥有或者说对应一个Class的实例对 ...
- [SDOI 2008]仪仗队
Description 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是 ...
- Evensgn 捡树枝
问题 A: Evensgn 剪树枝 时间限制: 1 Sec 内存限制: 128 MB 题目描述 繁华中学有一棵苹果树.苹果树有 n 个节点(也就是苹果),n − 1 条边(也就 是树枝).调皮的 E ...
- 计蒜客NOIP2017提高组模拟赛(三)day2-数三角形
传送门 这题有点坑啊 设A为两边颜色不同的角,B为两边颜色相同的角 那么考虑三种三角形:异色,同色,其他 对于任何一个异色三角形,一定会有三个颜色不同的角, 对于任何一个同色三角形,一定会有零个颜色不 ...
- UVA140 ——bandwidth(搜索)
Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an ordering on the ...
- hdu 5119(2014北京)
题意: 随机选择一个数,如果后面有比他小的就进行交换,直到没有为止(算一轮).求多少轮后为递增序列 思路: 倒着找,如果有比经过的最小数大的,ans+1 #include <iostream&g ...