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. 介绍开源的项目管理系统-Redmine

    介绍开源的项目管理系统-Redmine 分类: Redmine2009-06-01 10:12 1047人阅读 评论(0) 收藏 举报 项目管理subversionphpmyadminrailsaut ...

  2. .NET MVC4 实训记录之一(引入Unity3.0 Ioc框架)

    一直在做维护项目,没有机会接触完整的架构,于是自学.NET MVC.自今日起,将自学的过程.遇到的问题以及解决方案记录下来. 在WebApp项目中右键,使用NuGet引入Unity3.0.

  3. 总结windows多线程同步互斥

    windows多线程同步互斥--总结 我的windows多线程系列文章: windows多线程--原子操作 windows多线程同步--事件 windows多线程同步--互斥量 windows多线程同 ...

  4. 程序媛也会画图 之 在ubuntu下用GIMP制作gif

    动画是什么?就是几张图片很快的顺序播放嘛,今天就画画gif小图吧,以后在演示效果图的时候也用的上. 1.准备一个小图 就用小绿人好了 2.打开GIMP 3.新建一个图片打开  文件 ->新建输入 ...

  5. AngularJS的工作原理1

    AngularJS的工作原理 个人觉得,要很好的理解AngularJS的运行机制,才能尽可能避免掉到坑里面去.在这篇文章中,我将根据网上的资料和自己的理解对AngularJS的在启动后,每一步都做了些 ...

  6. 1572: [Usaco2009 Open]工作安排Job[贪心]

    Description Farmer John 有太多的工作要做啊!!!!!!!!为了让农场高效运转,他必须靠他的工作赚钱,每项工作花一个单位时间. 他的工作日从0时刻开始,有1000000000个单 ...

  7. SHELL编程笔记(二)之shell流程控制

    Shell控制流程结构 本章内容有:   退出状态   While.for和until loops循环   If then else语句   脚本中动作   菜单 条件控制语句 If then els ...

  8. [转]影响Cache的几个HTTP头信息

    原文地址:http://hi.baidu.com/feilala_fly/item/f79eca08fbf389026c9048a7 Http的Cache机制总共有4个组成部分: Cache-Cont ...

  9. 一个简单的EXTJS案例

    aria-form.js Ext.require([ 'Ext.form.*', 'Ext.layout.container.Column', 'Ext.tab.*' ]); Ext.onReady( ...

  10. OpenCV249 for python278 最简配置方案

    跟很多开源软件一样OpenCV也提供了完善的Python接口,非常便于调用.OpenCV 包含了超过 2500 个算法和函数,几乎任何一个能想到的成熟算法都可以通过调用OpenCV的函数来实现,超级方 ...