http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829

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

题目思路,刚开始我以为只有能被3或5整除的数为beautiful number,英语翻译过来后是只要能被3或5整除的数为beautiful number,那么就简单了,

预处理一下,map映射随便做。注意,最大是第100000个数,而不是beautiful number最大是100000。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
map<ll,ll>m;
void getbeautifulnumber()
{
int p=;
for(int i=; ;i++)
{
if(p>) break;
if(i%== || i%==)
m[p++]=i;
}
}
int main()
{
int n;
getbeautifulnumber();
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",m[n]);
}
return ;
}

Beautiful Number的更多相关文章

  1. Codeforces 55D Beautiful Number

    Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...

  2. zoj Beautiful Number(打表)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 题目描述: Mike is very lucky, as ...

  3. beautiful number 数位DP codeforces 55D

    题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...

  4. zoj 2829 Beautiful Number

    Beautiful Number Time Limit: 2 Seconds      Memory Limit: 65536 KB Mike is very lucky, as he has two ...

  5. hdu 5179 beautiful number

    beautiful number 问题描述 令 A = \sum_{i=1}^{n}a_i * {10}^{n-i}(1\leq a_i \leq 9)A=∑​i=1​n​​a​i​​∗10​n−i​ ...

  6. HDU 5179 beautiful number (数位dp / 暴力打表 / dfs)

    beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. Codeforces 55D Beautiful Number (数位统计)

    把数位dp写成记忆化搜索的形式,方法很赞,代码量少了很多. 下面为转载内容:  a positive integer number is beautiful if and only if it is  ...

  8. cf B Very Beautiful Number

    题意:给你两个数p和x,然后让你找出一个长度为p的数,把它的最后移到最前面之后得到的数是原来数字的x倍,有很多这样的数取最小. 思路:枚举最后一位,然后就可以推出整个的一个数,然后比较得到的数的第一个 ...

  9. 【HDOJ】5179 beautiful number

    DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include & ...

随机推荐

  1. vue安装踩坑系列

    1.安装npm node环境 2.npm install vue-cli -g 安装vue-cli vue-V检测脚手架是否安装成功 3.vue init webpack vuecliTest 初始化 ...

  2. Windows API Hook

    原文地址:http://blog.sina.com.cn/s/blog_628821950100xmuc.html 原文对我的帮助极大,正是由于看了原文.我才学会了HOOK.鉴于原文的排版不是非常好, ...

  3. Android 经常使用工作命令mmm,mm,m,croot,cgrep,jgrep,resgrep,godir

    官方定义: Invoke ". build/envsetup.sh" from your shell to add the following functions to your ...

  4. js 实现 水仙花数

    水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3+ 3^3 = 153) <!DOCTYPE html><html ...

  5. js变量作用域和闭包的示例

    <script> /* js是函数级作用域,在函数内部的变量,内部都能访问, 外部不能访问内部的,但是内部可以访问外部的变量 闭包就是拿到本不该属于他的东西,闭包会造成内存泄漏,你不知道什 ...

  6. Framework3.5安装(Windows8.1)

    在用到Android逆向助手,使用时提示安装Framework3.5,Windows7都有Framework3.5,Windows8却没有,联网更新就算了,这龟速更新得多久.但是问题总还是要解决,随便 ...

  7. 解决高版本vm打开虚拟机报错

    问题: 打开虚拟机的文件目录,找到.vmx 文件 用记事本打开重命名后的“.vmx.txt”文件 找到行:policy.vm.mvmtid = "52 10 08 ed ff 34 ed d ...

  8. Android chromium 2

    Overview JNI (Java Native Interface) is the mechanism that enables Java code to call native function ...

  9. webpack的理解

    webpack是一个模块打包工具,你可以使用webpack管理你的模块依赖,并编译输出模块们所需要的静态文件.它能够很好的管理.打包Web开发中所用到的HTML.Javascript.CSS以及各种静 ...

  10. python supper()函数

    参考链接:https://www.runoob.com/python/python-func-super.html super() 函数是用于调用父类(超类)的一个方法. class Field(ob ...