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 ...
随机推荐
- python 调用shell或windows命令
目前使用到的有两种方式:os.system()和os.popen() import os os.system('cd e:cjx') #调用后返回执行结果状态 如果想获得返回结果,则使用以下方式: i ...
- 数据库sqlite的使用
#import <Foundation/Foundation.h> @class student; @interface DataBaseHandle : NSObject //设置单例 ...
- SQL Server 造成cpu 使用率高的 6 原因
第一种: 编译和重编译执行计划. 第二种: 排序与聚合. 第三种: 表格连接操作. 第四种: max degree of parallelism. 第五种: max worker threads. 第 ...
- 构建混合云:配置Azure site to site VPN连接(2)
那么接下来的部分,我们开始正式配置S2S VPN: 首先配置本地网络,什么是本地网络呢?如果你在Azure上配置,本地网络意思是你自己的数据中心需要和Azure进行连接的网络段,而不是Azure上的网 ...
- git 的一些使用和命令
http://git.oschina.net/progit/2-Git-%E5%9F%BA%E7%A1%80.html(pro git) git branch (展示本地当前的所有分支,以及当前 ...
- DataTable AsEnumerable 的使用
var p = DataTable.AsEnumerable().Where(t => t.Field<int>("ChannelID") == int.Pars ...
- 几种MEMS陀螺仪(gyroscope)的设计和性能比较
现在市场上的MEMS陀螺仪主要有SYSTRON.BOSCH和INVENSENSE设计和生产.前两者设计的陀螺仪属高端产品,主要用于汽车.后者的属低端产品,主要用于消费类电子,象任天堂的Wii.ADI2 ...
- nginx配置方法
nginx配置的代码: user www www; worker_processes 8; error_log /data111/logs/nginx/nginx-error.log crit; pi ...
- hdu 1181 变形课(dfs)
Problem Description 呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个 ...
- cf公式专场-续
Benches Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Statu ...