poj1316
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 20864 | Accepted: 11709 |
Description
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
Source
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXn = ;
int numOf_Digit(int number)
{
int sum = number;
while(number>=)
{
sum += number%;
number /=;
}
sum+=number ;
return sum;
}
bool vis[MAXn];
int main()
{ memset(vis,true,sizeof(vis));
for(int i=;i<;i++)
{
int t =numOf_Digit(i);
vis[t] = false;
}
for(int i = ;i<;i++)
if(vis[i]==true)
printf("%d\n",i);
return ;
}
当然直接把#define 去掉,直接就是vis[10000],并且取消掉那个运算函数,用一句int t = i + i/1000+(i/100)%10+(i/10)%10+i%10; 就可以0MS了,但个人风格,喜欢把功能变成函数
poj1316的更多相关文章
- A过的题目
1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...
随机推荐
- Financial Management--hdu1064
Financial Management Problem Description Larry graduated this year and finally has a job. He’s makin ...
- 经典面试题(二)附答案 算法+数据结构+代码 微软Microsoft、谷歌Google、百度、腾讯
1.正整数序列Q中的每个元素都至少能被正整数a和b中的一个整除,现给定a和b,需要计算出Q中的前几项, 例如,当a=3,b=5,N=6时,序列为3,5,6,9,10,12 (1).设计一个函数void ...
- Web常用函数介绍(LoadRunner相关)
介绍大纲:1. web_url2. web_image3. web_link4. web_submmit_form 详细介绍: 一. web_url web_url 语法: Int Web_url(c ...
- Ubuntu 12.04安装NFS server
首先安装nfs-kernel-server apt-get install nfs-kernel-server 然后创建一个目录: mkdir -p /opt/share 并赋予权限777: chmo ...
- Baidu Sitemap Generator插件使用图解教程
这两天因为百度对本博客文章收录更新很慢,一直在网络查找真正的原因和解决方法.最终发现了柳城开发的Baidu Sitemap Generator WordPress插件,最终效果如果还需要验证一段时间. ...
- linux之SQL语句简明教程
本教程参考http://www.1keydata.com/cn/sql/ 目的是让初学者了解linux下Mysql的操作,但是我仍想侧重于SQL语句的讲解 sql语句的学习将按照下图的流程: 当然在这 ...
- 【HDU】4092 Nice boat(多校第四场1006) ——线段树 懒惰标记
Nice boat Time Limit: 30000/15000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) To ...
- leetcode 326. Power of Three(不用循环或递归)
leetcode 326. Power of Three(不用循环或递归) Given an integer, write a function to determine if it is a pow ...
- RHEL5.8安装Oracle11g
1.安装环境[root@rusky-oracle11g ~]# uname -r2.6.18-308.el5[root@rusky-oracle11g ~]# cat /etc/issueRed Ha ...
- C#运用实例.读取csv里面的词条,对每一个词条抓取百度百科相关资料,然后存取到数据库
第一步:首先需要将csv先装换成datatable,这样我们就容易进行对datatable进行遍历: /// 将CSV文件的数据读取到DataTable中 /// CSV文件路径 /// 返回读取了C ...