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 ...
随机推荐
- c语言一个显示星号的函数(隐藏密码)
显示星号 void star(char p[]) //显示星号 { int j; while((p[j] = getch())!='\r') { if(p[j] !='\b') { pr ...
- global与nonlocal关键字总结
global适用于函数内部修改全局变量的值 nonlocal适用于嵌套函数中内部函数修改外部变量的值 如果没有使用以上关键字,对全局变量或者外部变量进行修改,python会默认将全局变量隐藏起来 例1 ...
- JEECG中的模糊查询
以一个使用代码生成器创建的通讯录(maillist)为例: @RequestMapping(params = "datagrid") public void datagrid(Ma ...
- 列表(list)之一定义 添加 删除 排序 反转 索引等其他操作
1.定义: 创建一个列表,只要把逗号分隔的不同的数据项使用方括号括起来即可,序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推. # 列表list1=[&q ...
- ssh爆破(python脚本)
最近在乌云看到一份端口详解:为了锻炼自己,按照端口详解写脚本 #!/usr/local/bin/ python # -*- coding: UTF-8 -*- __author__ = 'yangxi ...
- [PA 2014]Pakowanie
Description 你有n个物品和m个包.物品有重量,且不可被分割:包也有各自的容量.要把所有物品装入包中,至少需要几个包? Input 第一行两个整数n,m(1<=n<=24,1&l ...
- Codeforces 547D Mike and Fish
Description 题面 题目大意:有一个的网格图,给出其中的 \(n\) 个点,要你给这些点染蓝色或红色,满足对于每一行每一列都有红蓝数量的绝对值之差不超过1 Solution 首先建立二分图, ...
- ●BZOJ 2154 Crash的数字表格
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2154 题解: 莫比乌斯反演. 题意还是很清楚的,就不赘述了. 显然有 $ANS=\sum_{ ...
- operator[] 和 insert
operator[] 和 insert: map的[]操作和其他容器和内置[]没有关系 如果我们通过[]向map中插入or更新值,需要考虑一些东西 1.键已经存在,那么直接进行修改即可 2.键不存在, ...
- hihocoder——1041国庆出游(搜索)
描述 小Hi和小Ho准备国庆期间去A国旅游.A国的城际交通比较有特色:它共有n座城市(编号1-n):城市之间恰好有n-1条公路相连,形成一个树形公路网.小Hi计划从A国首都(1号城市)出发,自驾遍历所 ...