Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description
I will show you the most popular board game in the Shanghai Ingress Resistance Team.
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.

 



Input
The first line of input contains an integer t (1≤t≤500000), the number of test cases. t test cases follow. Each test case provides one integer n (1≤n≤109).
 



Output
For each test case, output one line with only one integer corresponding to the shortest "I Count Two Three Number" no smaller than n.
 



Sample Input
10
1
11
13
123
1234
12345
123456
1234567
12345678
123456789
 



Sample Output
1
12
14
125
1250
12348
123480
1234800
12348000
123480000
 
先打表,然后二分搜索做
 #include <iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<set>
using namespace std;
int t,x,len;
int arr[];
int main()
{
len=;
for(int a=;a<=;a++)
{
double aa=pow(2.0,a*1.0);
for(int b=;b<=;b++)
{
double bb=pow(3.0,b*1.0);
if (aa*bb>=1200000000.0) break;
for(int c=;c<=;c++)
{
double cc=pow(5.0,c*1.0);
if (aa*bb*cc>=1200000000.0) break;
for(int d=;d<=;d++)
{
double dd=pow(7.0,d*1.0);
if (aa*bb*cc*dd>=1200000000.0) break;
arr[++len]=(int)aa*bb*cc*dd;
}
}
}
}
sort(arr+,arr+len+);
//printf("%d\n",arr[len]);
//for(int i=1;i<=len;i++) printf("%d ",arr[i]);
// printf("%d\n",len);
while(scanf("%d",&t)!=EOF)
{
for(;t>;t--)
{
scanf("%d",&x); // set<int> s;
// s.insert(1);
// while(!s.empty())
// {
// set<int>::iterator ii;
// ii=s.begin();
// if (*ii>=x) {printf("%d\n",*ii); break;}
// s.erase(s.begin());
// int k=*ii;
// if(k*2<1200000000) s.insert(k*2);
// if(k*3<1200000000) s.insert(k*3);
// if(k*5<1200000000) s.insert(k*5);
// if(k*7<1200000000) s.insert(k*7);
// } int l=,r=len;
while(l<r)
{
int mid=(l+r)/;
if (arr[mid]<x) l=mid+;
else r=mid;
}
printf("%d\n",arr[l]); }
}
return ;
}

2016 ACM/ICPC Asia Regional Qingdao Online 1001 I Count Two Three(打表+二分搜索)的更多相关文章

  1. 2016 ACM/ICPC Asia Regional Qingdao Online 1001 I Count Two Three

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...

  2. 2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分

    I Count Two Three Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  3. 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^ ...

  4. 数学--数论--HDU--5878 Count Two Three 2016 ACM/ICPC Asia Regional Qingdao Online 1001

    I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...

  5. HDU 5889 Barricade 【BFS+最小割 网络流】(2016 ACM/ICPC Asia Regional Qingdao Online)

    Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  6. 2016 ACM/ICPC Asia Regional Qingdao Online(2016ACM青岛网络赛部分题解)

    2016 ACM/ICPC Asia Regional Qingdao Online(部分题解) 5878---I Count Two Three http://acm.hdu.edu.cn/show ...

  7. hdu 5868 2016 ACM/ICPC Asia Regional Dalian Online 1001 (burnside引理 polya定理)

    Different Circle Permutation Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K ...

  8. 2016 ACM/ICPC Asia Regional Qingdao Online

    吐槽: 群O的不是很舒服 不知道自己应该干嘛 怎样才能在团队中充分发挥自己价值 一点都不想写题 理想中的情况是想题丢给别人写 但明显滞后 一道题拖沓很久 中途出岔子又返回来搞 最放心的是微软微软妹可以 ...

  9. 【2016 ACM/ICPC Asia Regional Qingdao Online】

    [ HDU 5878 ] I Count Two Three 考虑极端,1e9就是2的30次方,3的17次方,5的12次方,7的10次方. 而且,不超过1e9的乘积不过5000多个,于是预处理出来,然 ...

随机推荐

  1. .NET反射的优化

    写在前面 1)本篇博客并非原创,而是我针对.NET反射相关知识的总结.本篇内容来源汇总于3篇博客.在后面的介绍中会在开头给出对应的链接,方便读者自行学习.2)本篇博客主要针对表达式树代码进行详细讲解. ...

  2. python 时间戳转元组

    #!/usr/bin/python # -*- coding: UTF- -*- import time localtime = time.localtime(time.time()) print(& ...

  3. python 分数的数学四则运算

    import fractions f1 = fractions.Fraction(, ) f2 = fractions.Fraction(, ) print('{} + {} = {}'.format ...

  4. deque_01

    A.头尾 添加/移除 A.1.deque::push_back(elemValue); A.2.deque::pop_back(); A.3.deque::push_front(elemValue); ...

  5. Spring生态顶级项目说明

    1.Spring IO platform 说明:用于系统部署,是可集成的,构建现代化应用的版本平台 2.Spring Boot 说明:旨在简化创建产品级的 Spring 应用和服务,简化了配置文件,使 ...

  6. c++ primer plus 第三章 课后题答案

    #include<iostream> using namespace std; int main() { ; int shen_gao; cout <<"Please ...

  7. Windows 2012 R2 创建AD域

    创建复数的域控制器,容错的同时(一台AD故障),且能提高用户的登录效率. 为了实现负载平衡,域配置前,两台Ad域的DNS应该按如下设置,同时,也为了避免在AD02上,选择“将域控制器添加到现有域”时出 ...

  8. CentOS系统-常用组件安装

    1,安装系统后,补装包组yum groupinstall "Compatibility libraries" "Base" "Development ...

  9. 通过IIS寄宿WCF服务

    WCF全面解析一书中的例子S104,直接将Service目录部署到iis是无法得到服务相应的,需要在项目中新建一个web项目,删除掉自动生成的所有文件之后,把Service目录下的Calculator ...

  10. 3-23Agile Web Development,3-24(chapter: 6)

    第2章 Instant Gratification 复习 和 练习第一章,新建rails web页面. 重点: 知道了类,方法,实例变量 在rails是怎么用的. rails generate con ...