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. python后端工程师 数据爬虫

    大数据挖掘分析平台和产品的建设. 工作职责: 独立完成软件系统代码的设计与实现: 根据需求完成设计,代码编写,调试,测试和维护: 使用Python 语言对后台业务逻辑进行开发以及维护: 能根据实际需求 ...

  2. .NET反射的优化

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

  3. 获取CheckBox的值

    前台获取 function chkCheckBox() { var code_arr = new Array(); //定义一数组 $('.C_B').each(function () { if ($ ...

  4. Mui --- 弹出菜单

    mui框架内置了弹出菜单插件,弹出菜单显示内容不限,但必须包裹在一个含.mui-popover类的div中,如下即为一个弹出菜单内容: <div id="popover" c ...

  5. 关于xargs cp中,如何确定拷贝的源和目的 (copied)

    Seker: find . -name "*" |xargs cp ???? 这里 xargs cp 怎么区分cp源 和 cp目的 例如:想把 查询到的文件 都copy到/home ...

  6. python group()--转载

    import re a = "123abc456" print re.search("([0-9]*)([a-z]*)([0-9]*)",a).group(0) ...

  7. React Native之进度条ProgressViewIOS的使用

    import React,{Component}from 'react'; import { AppRegistry, StyleSheet, Text, View, ProgressViewIOS, ...

  8. chrome的url列表里面也找不到chrome://plugins的原因

    plugins 页面被移除后,可以访问: chrome://settings/content 调整 Flash.PDF 的设置. 原本 plugins 页面就基本只剩下这两货了,移除掉确实没啥影响. ...

  9. Java入门:零碎的知识点

    实例变量经常被称为属性 成员变量和局部变量:前者在类中定义,后者在类的方法中定义且系统不会自动赋初始值 我们创建一个对象的时候实际上执行的是无参的构造方法 静态变量 static String arr ...

  10. (转)netty、mina性能对比分析

    转自: http://blog.csdn.net/mindfloating/article/details/8622930 流行 NIO Framework netty 和 mina 性能测评与分析 ...