ZOJ.2829 Beautiful Number【水】 2015/09/22
来源:互联网 发布:蝴蝶效应 知乎 编辑:程序博客网 时间:2024/06/04 20:04
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
Author: MAO, Yiqiang
Source: Zhejiang University Local Contest 2007, Preliminary
水,打表即可。
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int p[100010],n;void init(){ int k = 1; for( int i = 3 ; i <= 300000 ; ++i ){ if( i % 3 == 0 || i % 5 == 0 ){ p[k++] = i; } if( k > 100000 ) break; }}int main(){ init(); while( ~scanf("%d",&n) ){ printf("%d\n",p[n]); } return 0;}
0 0
- ZOJ.2829 Beautiful Number【水】 2015/09/22
- ZOJ 2829 Beautiful Number
- zoj 2829 Beautiful Number
- ZOJ 2829 Beautiful Number
- ZOJ 2829 Beautiful Number
- zoj 2829 Beautiful Number(水~)
- ZOJ 2829 Beautiful Number(睡前一水)
- ZOJ Problem Set - 2829 Beautiful Number
- STL-ZOJ-2829 Beautiful Number:打表的艺术&&map映照容器
- zoj 2850 Beautiful Meadow(水~)
- [水] zoj 2850 Beautiful Meadow
- ZOJ.3336 Friend Number II【有点水】 2015/10/09
- ZOJ.3418 Binary Number【异或】 2015/09/22
- ZOJ.1526 Big Number【对数】 2015/09/22
- HDU 5179 beautiful number 数位DP(水)
- zoj 2850 Beautiful Meadow
- zoj 3213 Beautiful Meadow
- ZOJ 2850 Beautiful Meadow
- Android 自定义 DialogFragment 宽度问题
- hihocoder 1233 Boxes(bfs+状态压缩+hash表)
- linux中对文件名包含空格时处理异常的解决方法
- js的时间戳和php的时间戳转换需要注意的地方
- 注册功能实现
- ZOJ.2829 Beautiful Number【水】 2015/09/22
- 友善之臂第一个裸板驱动LED程序的详细分析(新手向)
- 【学习笔记】系列二:Linux安装配置apache
- document.addEventListener理解
- Android 关闭多个Activity
- 函数执行过程的博大精深,表示不懂啊
- Jquery控制文字横向移动
- orcacle 解决违反约束问题
- Ecmall MySql 数据库调用教程