zoj 2829 Beautiful Number
Beautiful Number
Time Limit: 2 Seconds Memory Limit: 65536 KB
Mike is very lucky, as he has two beautiful numbers, 3 and 5. But he is so greedy that he wants infinite beautiful numbers. So he declares that any positive number which is dividable by 3 or 5 is beautiful number. Given you an integer N (1 <= N <= 100000), could you please tell mike the Nth beautiful number?
Input
The input consists of one or more test cases. For each test case, there is a single line containing an integer N.
Output
For each test case in the input, output the result on a line by itself.
Sample Input
1
2
3
4
Sample Output
3
5
6
9
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
vector<int> v;
int main(){
int n = , i = , num;
while(){
if(n > )
break;
if(i % == || i % == ){
v.push_back(i);
n++;
}
i++;
}
while(cin >> num){
printf("%d\n", v[num - ]);
}
return ;
}
zoj 2829 Beautiful Number的更多相关文章
- poj 3100 (zoj 2818)||ZOJ 2829 ||ZOJ 1938 (poj 2249)
水题三题: 1.给你B和N,求个整数A使得A^n最接近B 2. 输出第N个能被3或者5整除的数 3.给你整数n和k,让你求组合数c(n,k) 1.poj 3100 (zoj 2818) Root of ...
- Beautiful Number
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 Beautiful Number Time Limit: 2 Sec ...
- zoj Beautiful Number(打表)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 题目描述: Mike is very lucky, as ...
- Codeforces 55D Beautiful Number
Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...
- beautiful number 数位DP codeforces 55D
题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...
- hdu 5179 beautiful number
beautiful number 问题描述 令 A = \sum_{i=1}^{n}a_i * {10}^{n-i}(1\leq a_i \leq 9)A=∑i=1nai∗10n−i ...
- HDU 5179 beautiful number (数位dp / 暴力打表 / dfs)
beautiful number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Codeforces 55D Beautiful Number (数位统计)
把数位dp写成记忆化搜索的形式,方法很赞,代码量少了很多. 下面为转载内容: a positive integer number is beautiful if and only if it is ...
- ZOJ 3622 Magic Number 打表找规律
A - Magic Number Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Subm ...
随机推荐
- 初探Hibernate3源码--读取配置文件
依照个人推测,要实现ORM框架,关键是如何拼凑sql语句再通过jdbc来进行对数据库的访问,另外将数据库返回的数据记录封装成对应的类也是必不可少的. 那么实现ORM框架的基本思路如下: 1,读取xml ...
- 150 Evaluate Reverse Polish Notation 逆波兰表达式求值
求在 逆波兰表示法 中算术表达式的值.有效的运算符号包括 +, -, *, / .每个运算对象可以是整数,也可以是另一个逆波兰计数表达.例如: ["2", "1&quo ...
- Linux常用命令awk
awk能够处理类似csv这种按行格式的数据,对每一行record按照-F指定的分隔符切割,然后处理.默认支持空格和\t分隔符 1.统计文件里某一列数据等于某个值的个数 -0_djt10.txt 2.拼 ...
- spark block读写流程分析
之前分析了spark任务提交以及计算的流程,本文将分析在计算过程中数据的读写过程.我们知道:spark抽象出了RDD,在物理上RDD通常由多个Partition组成,一个partition对应一个bl ...
- [转]利用telnet进行SMTP的验证
本文转自:http://www.cnblogs.com/rootq/articles/1320266.html [crazywill@localhost crazywill]$ telnet #tel ...
- windows下常用的一些shell命令
看的视频上都是linux系统的shell命令,和windows区别很多.所以整理了windows常用的一些shell命令. 注意:并不是每个都试验过,使用时还需自己验证下. 学system和os,su ...
- 【经验总结】VS2010下建立MFC程序
孙鑫的MFC教学视频非常不错,但是由于视频中孙鑫老师采用VC6.0版本,而现在 许多人都转向了使用VS,VS为我们生成了许多不需要的代码,这也导致在这节课的学习编程中总是遇到一些困难.那么,如何去掉这 ...
- 关于setTimeout和Promise执行顺序问题
先看一段代码 console.log('打印'+1); setTimeout(function(){ console.log('打印'+2); }) new Promise(function(reso ...
- Javaweb之xml
1 XML概述 1.1 XML是什么? eXtensible Markup Language可扩展标记语言 1.2 XML作用 主要是用于描述数据,而 ...
- 错误:Implicit super constructor xx() is undefined for default constructor.
因为父类定义了一个有参的构造函数且父类中没有默认的无参构造方法,此时编译器不会为你调用默认的构造函数,当子类继承时,必须在自己的构造函数显式调用父类的构造函数,才能确保子类在初始化前父类会被实例化,如 ...