hdu 5878
I Count Two Three
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2719 Accepted Submission(s): 1177
It all started several months ago.
We found out the home address of the enlightened agent Icount2three and decided to draw him out.
Millions of missiles were detonated, but some of them failed.
After the event, we analysed the laws of failed attacks.
It's interesting that the i-th attacks failed if and only if i can be rewritten as the form of 2a3b5c7d which a,b,c,d are non-negative integers.
At recent dinner parties, we call the integers with the form 2a3b5c7d "I Count Two Three Numbers".
A related board game with a given positive integer n from one agent, asks all participants the smallest "I Count Two Three Number" no smaller than n.
1
11
13
123
1234
12345
123456
1234567
12345678
123456789
12
14
125
1250
12348
123480
1234800
12348000
123480000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <vector>
#include <set>
using namespace std;
#define ll long long
#define P pair<int,int>
const int N= 5e3+;
const ll M = ;
ll n,a[N];
int cnt =;
int t;
ll pow(ll a,ll b){
ll ans=;
while(b){
if(b&) ans=ans*a;
b>>=;
a*=a;
}
return ans;
}
void init()
{
ll i,j,k,l;
for(i=;i<=;i++){
if(pow(,i)>M) break;
for(j=;j<=;j++){
if(pow(,i)*pow(,j)>M) break;
for(k=;k<=;k++) {//k++后,l 再次从0开始。
if(pow(,i)*pow(,j)*pow(,k)>M) break;
for(l=;l<=;l++){
if(pow(,i)*pow(,j)*pow(,k)*pow(,l)>M) break;//在这里跳出才可以继续循环
a[cnt++] = pow(,i)*pow(,j)*pow(,k)*pow(,l);
}
}
}
}
sort(a,a+cnt);
}
int main()
{ init();
scanf("%d",&t);
while(t--){
scanf("%lld",&n);
printf("%lld\n",a[lower_bound(a,a+cnt,n)-a]);
}
return ;
}
hdu 5878的更多相关文章
- hdu 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5878 题目大意: 给出一个数n ,求一个数X, X>=n. X 满足一个条件 X= 2^a*3^ ...
- HDU 5878 I Count Two Three (打表+二分查找) -2016 ICPC 青岛赛区网络赛
题目链接 题意:给定一个数n,求大于n的第一个只包含2357四个因子的数(但是不能不包含其中任意一种),求这个数. 题解:打表+二分即可. #include <iostream> #inc ...
- HDU 5878 I Count Two Three
I Count Two Three Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- I Count Two Three HDU - 5878(暴力二分)
为甚么16年Qingdao Online 都是暴力题emm///... 先暴力预处理 然后lower _bound二分 #include <iostream> #include <c ...
- HDU - 5878 2016青岛网络赛 I Count Two Three(打表+二分)
I Count Two Three 31.1% 1000ms 32768K I will show you the most popular board game in the Shanghai ...
- HDU 5878 I Count Two Three (预处理+二分查找)
题意:给出一个整数nnn, 找出一个大于等于nnn的最小整数mmm, 使得mmm可以表示为2a3b5c7d2^a3^b5^c7^d2a3b5c7d. 析:预处理出所有形为2a3 ...
- 数学--数论--hdu 5878 I Count Two Three(二分)
I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...
- 【2016 ACM/ICPC Asia Regional Qingdao Online】
[ HDU 5878 ] I Count Two Three 考虑极端,1e9就是2的30次方,3的17次方,5的12次方,7的10次方. 而且,不超过1e9的乘积不过5000多个,于是预处理出来,然 ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
随机推荐
- 洛谷 P4503 [CTSC2014]企鹅QQ
暴力枚举不同的一位即可.. 主要是常数问题 1.统计答案时用sort速度快于用tr1/unordered_map,后者又快于map (tr1/unordered_map完全达不到理论复杂度上的O(1) ...
- 安卓新的联网方式 Volley的使用(一)加载图片与 json
最近刚接触安卓, 以前搞wp ,一对比起来 ,安卓怎么这么麻烦.联网必须要重新开一个线程才可以.而且加载网络图片也很麻烦...花了很久一直卡在快速滑动加载网络图片的listview上面 ,一直很纠结痛 ...
- DDX和DDV——控件与变量之间值的传递
DoDataExchange由框架调用,作用是交互并且验证对话框数据,主要由(DDX) 和 (DDV)宏实现. 永远不要直接调用这个函数,而是通过UpdateData(TRUE/FALSE)实现控件与 ...
- FastDFS java 辅助类
package cn.saiz.drkms.task.crack.utils; import java.io.File; import java.io.FileInputStream; import ...
- [问题解决]Deepin环境变量设置无效解决
将环境变量的设置放在这里: gedit ~/.bashrc 详见参考: linux下如何设置环境变量PATH : http://blog.csdn.net/witsmakemen/article/d ...
- 2840 WIKIOI——评测
2840 WIKIOI——评测 时间限制: 1 s 空间限制: 2000 KB 题目等级 : 白银 Silver 题目描述 Description Wikioi上有一题有N个测试点,时限为 ...
- CString的GetBuffer和ReleaseBuffer
GetBuffer()主要作用是将字符串的缓冲区长度锁定,releaseBuffer则是解除锁定,使得CString对象在以后的代码中继续可以实现长度自适应增长的功能. CString ::GetBu ...
- MyEclipse中把java项目打包——含有第三方jar包【转】
也适用于eclipse导出jar. 在将项目打包为jar包时一直出现“ClassNotDefFound”错误,百度了很多解决办法都没有解决.最终找到一个很好的解决办法. 1.打包步骤 (1)右键单击j ...
- Azure 项目构建 – 构建直播教学系统之媒体服务篇
本课程主要介绍如何在 Azure 平台上快速构建和部署基于 Azure 媒体服务的点播和直播教学系统, 实践讲解如何使用 Azure 门户创建媒体服务, 配置视频流进行传输,连接 CDN 加速等. 具 ...
- PHP开发基础视频教程
PHP现今作为互联网运用很广泛的编程语言,市场需求量也越来越高,而PHP开发工程师的薪资也是一路水涨船高,更多的人看到了PHP的发展前景,纷纷都想投入到PHP的开发大军中来,那么对于很多转行或者零基础 ...