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 ...
随机推荐
- 使用Hexo 搭建自己的博客
使用Hexo 搭建自己的博客 最近一直都想着如何去搭建属于自己的博客,有空的时候就写写文章什么的. 本人对该博客系统的要求是: 博文的编写要采用现在流行的MarkDown来进行编写. 本人还不想去注册 ...
- centos安装openldap过程
1.下载软件如下,db是数据库 2.首先安装数据库db # tar xf db-4.8.30.tar.gz # cd db-4.8.30 # cd build_unix/ (# ../dist/con ...
- python入门之运算符
计算运算符 + 加 - 减 * 乘 / 除 % 取模,返回余数 ** 幂 // 取整除,返回商的整数部分 比较运算符 == 比较是否相等 != 比较是否不等于 <> 比较是否不等于 > ...
- BIO,NIO,AIO总结
熟练掌握 BIO,NIO,AIO 的基本概念以及一些常见问题是你准备面试的过程中不可或缺的一部分,另外这些知识点也是你学习 Netty 的基础. BIO,NIO,AIO 总结 1. BIO (Bloc ...
- spring boot使用AbstractXlsView导出excel
一.maven依赖jar包 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi ...
- dbf 工程模式连接(vfp c# )
首先现在微软官网下载“Microsoft OLE DB Provider for Visual FoxPro 9.0”驱动 下载完成后得到“VFPOLEDBSetup.msi” 双击安装即可在“C:\ ...
- Java之final、static关键字及匿名对象
个人通俗理解: 1.final:首先被final修饰的变量就自动变成的不能被修改的常量了.被修饰的类会自动变成太监类,只能有父类,不能有子类:被修饰的方法也不能被子类重写了:被修饰的引用变量值也不能更 ...
- debian中sudo无法使用问题
原文链接:http://sharadchhetri.com/2013/08/07/sudo-command-not-found-debian-7/ To solve this issue instal ...
- ES-windos环搭建-ik中文分词器
ik下载 打开Github官网,搜索elasticsearch-analysis-ik,单击medcl/elasticsearch-analysis-ik.或者直接点击 在readme.md文件中,下 ...
- 一张图告诉你,只会这些HTML还远远不够!!!!!
不知道自己HTML水平如何,不知道HTML5如何进化?看这张图 如果一半以上的你都不会,必须看这本书,阿里一线工程师用代码和功能页面来告诉你每一个技术点. 都会一点,但不知道如何检验自己,看看本书提供 ...