zoj Beautiful Number(打表)
题目链接:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829
题目描述:
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
/*问题 查询第几个漂亮数字是多少
解题思路 一般来讲,最直观的做法是将创建一个10 0000的数组,将每个漂亮数存进数组,最后查询即可*/
#include <cstdio>
int bn[];
int main()
{
int count=,i=;
while()
{
if(i % == || i % == ){
bn[count++]=i;
if(count > )
break;
}
i++;
}
int n;
while(scanf("%d",&n) != EOF)
{
printf("%d\n",bn[n]);
}
return ;
}
zoj Beautiful Number(打表)的更多相关文章
- HDU 5179 beautiful number (数位dp / 暴力打表 / dfs)
beautiful number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- zoj 2829 Beautiful Number
Beautiful Number Time Limit: 2 Seconds Memory Limit: 65536 KB Mike is very lucky, as he has two ...
- 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 ...
- 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 ...
- Beautiful Number
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 Beautiful Number Time Limit: 2 Sec ...
- ZOJ 3622 Magic Number 打表找规律
A - Magic Number Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Subm ...
- Codeforces 55D Beautiful Number (数位统计)
把数位dp写成记忆化搜索的形式,方法很赞,代码量少了很多. 下面为转载内容: a positive integer number is beautiful if and only if it is ...
- codeforces 893B Beautiful Divisors 打表
893B Beautiful Divisors 思路: 打表 代码: #include <bits/stdc++.h> using namespace std; #define _for( ...
随机推荐
- G 最水的一道
G - Here Be Dragons The Triwizard Tournament's third task is to negotiate a corridor of many segment ...
- 缓存中使用的ReentrantReadWriteLock锁
java中提供了lock锁,简便了设计缓存,下面程序主要是使用读写锁的应用.... import java.util.HashMap; import java.util.Map; import jav ...
- Windows核心编程:第2章 字符和字符串处理
Github https://github.com/gongluck/Windows-Core-Program.git //第2章 字符和字符串处理.cpp: 定义应用程序的入口点. // #incl ...
- c# List使用中遇到的问题
最近在项目上写的方法,想通过减少访问数据层,将需要重复调用的值存入List,无意中碰到的一个巨坑,至今仍不明所以,在此写出来,一来是看看有没有同道中人,二来是看看有没有大牛能解惑. 逻辑如下: 1.从 ...
- WPF TreeView BringIntoViewBehavior
由于项目需要,需要能够定位TreeView中的点,TreeView的节点数过多的情况下,即使找到了对应的节点并选中展示了,由于不在可视区域内,给用户的感觉还是不好,因此设计如下的Behavior,来实 ...
- .net图表之ECharts随笔07-自定义系列(多边形)
搞了一天多,才勉强搞出了一个不紧凑的六边形统计图,是真的菜. 这里ECharts的用法与06说的同一种,直接使用带all的js 先上个效果图,用面积来表示人数的多少 1. 参数option的toolt ...
- 动态分析小示例| 08CMS SQL 注入分析
i春秋作家:yanzm 0×00 背景 本周,拿到一个源码素材是08cms的,这个源码在官网中没有开源下载,需要进行购买,由某师傅提供的,审计的时候发现这个CMS数据传递比较复杂,使用静态分析的方式不 ...
- python3模块: requests
Python标准库中提供了:urllib等模块以供Http请求,但是,它的 API 太渣了.它是为另一个时代.另一个互联网所创建的.它需要巨量的工作,甚至包括各种方法覆盖,来完成最简单的任务. 发送G ...
- To B运营和To C运营到底有什么区别?
无论To B还是To C运营其本质都是从目标用户转化为付费用户实现产品的变现,但是两者之间仍然存在一定的区别. 单纯从概念上来说,To B和To C的区别主要是从电商兴起的,并随着互联网的快速发展,T ...
- docker学习实践之路[第四站]利用pm2镜像部署node应用
拉取keymetrics/pm2-docker-alpine:8镜像 docker pull keymetrics/pm2-docker-alpine: [8]为node镜像的版本号: 建立Docke ...