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 ...
随机推荐
- .net core页面使用layui的HtmlHelper扩展
Vino.Core.Extensions.Layui 如果您的.net core 2.0项目使用layui来渲染表单,那么您可以尝试使用这个扩展库可以帮你减少代码和工作量. 项目地址:https:// ...
- redis从入门到
下载 首先我们要到GitHub(https://github.com/MicrosoftArchive/redis/releases)上下载Source code (tar.gz) 上传到Linux上 ...
- 04、NetCore2.0下Web应用之Startup源码解析
04.NetCore2.0Web应用之Startup源码解析 通过分析Asp.Net Core 2.0的Startup部分源码,来理解插件框架的运行机制,以及掌握Startup注册的最优姿势. - ...
- 用委托(Delegate)的BeginInvoke和EndInvoke方法操作线程
让我们首先了解下什么时候用到C#异步调用: .NET Framework 允许您C#异步调用任何方法.定义与您需要调用的方法具有相同签名的委托:公共语言运行库将自动为该委托定义具有适当签名的Begin ...
- MySQL导致错误的语句
主键不唯一 由于表定义中创建了主键约束,因此MySQL将会确保重复主键不会被插入到数据表中. INSERT INTO person (person_id, fname, lname, gender, ...
- 【转载】C++基本功和 Design Pattern系列 ctor & dtor
最近实在是太忙了,无工夫写呀.只能慢慢来了.呵呵,今天Aear讲的是class.ctor 也就是constructor, 和 class.dtor, destructor. 相信大家都知道const ...
- 最新的Windows环境搭建zeroMQ并使用java代码运行zeromq详细教程
最近项目要用zeromq,linux上很好配置使用,但是windows上配置与使用没有找到合适的解决方案,看的很头疼,这里自己总结下供大家参考 准备工作: 1.libzmq下载地址:https://g ...
- spring源码阅读(1)bean解析
public class Test { public static void main(String[] args) throws Exception { BeanFactory beanFactor ...
- [USACO 09FEB]Fair Shuttle
Description 逛逛集市,兑兑奖品,看看节目对农夫约翰来说不算什么,可是他的奶牛们非常缺乏锻炼——如果要逛完一整天的集市,他们一定会筋疲力尽的.所以为了让 奶牛们也能愉快地逛集市,约翰准备让奶 ...
- [HNOI 2009]有趣的数列
Description 我们称一个长度为2n的数列是有趣的,当且仅当该数列满足以下三个条件: (1)它是从1到2n共2n个整数的一个排列{ai}: (2)所有的奇数项满足a1<a3<…&l ...