Beautiful Number
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的更多相关文章
- Codeforces 55D Beautiful Number
Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...
- zoj Beautiful Number(打表)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 题目描述: Mike is very lucky, as ...
- beautiful number 数位DP codeforces 55D
题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...
- 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 ...
- 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 ...
- cf B Very Beautiful Number
题意:给你两个数p和x,然后让你找出一个长度为p的数,把它的最后移到最前面之后得到的数是原来数字的x倍,有很多这样的数取最小. 思路:枚举最后一位,然后就可以推出整个的一个数,然后比较得到的数的第一个 ...
- 【HDOJ】5179 beautiful number
DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include & ...
随机推荐
- docker mysql镜像忽略表名大小写
原文:docker mysql镜像忽略表名大小写 1.安装mysql镜像 docker pull mysql/mysql-server 2.运行mysql docker run --net=host ...
- C#调用带结构体指针的C Dll的方法
在C#中调用C(C++)类的DLL的时候,有时候C的接口函数包含很多参数,而且有的时候这些参数有可能是个结构体,而且有可能是结构体指针,那么在C#到底该如何安全的调用这样的DLL接口函数呢?本文将详细 ...
- 和同事合作开发,使用局域网 git创建本地仓库
转自原文 和同事合作开发,使用局域网 git创建本地仓库 1.仓库 建一个空文件夹来做仓库,例如建为 cangku 1.1 cd 到 cangku目录下 创建远程仓库容器 mkdir mycangk ...
- Thinking in States
Thinking in States Niclas Nilsson PEOPLE IN THE REAL WORLD HAVE A WEIRD RELATIONSHIP WITH STATE. Thi ...
- MFC中CFileDialog使用方法
用CFileDialog选择了一个文件后,使用FILE::fopen打开文件错误,使用 的是相对地址.和王工调试了半天,怎么跟踪也没发现错误,原来如此. .... .. . . CFileDialog ...
- Android JNI和NDK学习(09)--JNI实例二 传递类对象
1 应用层代码 NdkParam.java是JNI函数的调用类,它的代码如下: package com.skywang.ndk; import android.app.Activity; impo ...
- C# Hook
C# Hook原理及EasyHook简易教程 前言 在说C# Hook之前,我们先来说说什么是Hook技术.相信大家都接触过外挂,不管是修改游戏客户端的也好,盗取密码的也罢,它们都是如何实现的呢? 实 ...
- 安卓开发--WebView
package com.zhangxi.test01; import android.app.Activity;import android.app.ProgressDialog;import and ...
- POJ 3122 Pie 二分答案
题意:给你n个派,每个派都是高为一的圆柱体,把它等分成f份,每份的最大体积是多少. 思路: 明显的二分答案题-- 注意π的取值- 3.14159265359 这样才能AC,,, //By Sirius ...
- MetaSploit攻击实例讲解------工具Meterpreter常用功能介绍(kali linux 2016.2(rolling))(详细)
不多说,直接上干货! 说在前面的话 注意啦:Meterpreter的命令非常之多,本篇博客下面给出了所有,大家可以去看看.给出了详细的中文 由于篇幅原因,我只使用如下较常用的命令. 这篇博客,利用下面 ...