I Count Two Three

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

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 2^a3^b5^c7^d "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
 

Source

 
枚举a,b,c,d,打表,二分查找
 //2016.9.17
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 10000
#define ll long long using namespace std; int arr[N]; ll pow(ll a, ll b)//快速幂
{
ll ans = ;
while(b)
{
if(b & )ans *= a;
a *= a;
b>>=;
}
return ans;
} int main()
{
ll tmp; int cnt = ;
for(int a = ; a < ; a++)
{
for(int b = ; b < ; b++)
{
for(int c = ; c < ; c++)
{
for(int d = ; d < ; d++)
{
tmp = pow(, a)*pow(, b);
if(tmp > 1e9)break;
tmp *= pow(, c);
if(tmp > 1e9)break;
tmp *= pow(, d);
if(tmp > 1e9)break;
arr[cnt++] = tmp;
}
}
}
}
sort(arr, arr+cnt);
int T, n;
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
int pos = lower_bound(arr, arr+cnt, n)-arr;
printf("%d\n", arr[pos]);
} return ;
}

HDU5878(打表)的更多相关文章

  1. 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 ...

  2. hdu5878(枚举,打表)

    题目链接:hdu5878 题意:到一行输入t,表示下面有t组数据,然后下面t行每行输入一个数n; 定义x==2^a*3^b*5^c*7^d(a, b, c, d为自然数,x不大于1e+9): 要求对于 ...

  3. hdu5878 I Count Two Three(二分+ 打表)

    题目链接:hdu5878 I Count Two Three 题意:给出一个整数n, 找出一个大于等于n的最小整数m, 使得m可以表示为2^a * 3^b * 5^c * 7^d​​. 题解:打表预处 ...

  4. In-Memory:在内存中创建临时表和表变量

    在Disk-Base数据库中,由于临时表和表变量的数据存储在tempdb中,如果系统频繁地创建和更新临时表和表变量,大量的IO操作集中在tempdb中,tempdb很可能成为系统性能的瓶颈.在SQL ...

  5. In-Memory:内存优化表的事务处理

    内存优化表(Memory-Optimized Table,简称MOT)使用乐观策略(optimistic approach)实现事务的并发控制,在读取MOT时,使用多行版本化(Multi-Row ve ...

  6. 试试SQLSERVER2014的内存优化表

    试试SQLSERVER2014的内存优化表 SQL Server 2014中的内存引擎(代号为Hekaton)将OLTP提升到了新的高度. 现在,存储引擎已整合进当前的数据库管理系统,而使用先进内存技 ...

  7. SQL Server表分区

    什么是表分区 一般情况下,我们建立数据库表时,表数据都存放在一个文件里. 但是如果是分区表的话,表数据就会按照你指定的规则分放到不同的文件里,把一个大的数据文件拆分为多个小文件,还可以把这些小文件放在 ...

  8. 一起学微软Power BI系列-使用技巧(5)自定义PowerBI时间日期表

    1.日期函数表作用 经常使用Excel或者PowerBI,Power Pivot做报表,时间日期是一个重要的纬度,加上做一些钻取,时间日期函数表不可避免.所以今天就给大家分享一个自定义的做日期表的方法 ...

  9. 分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间)

    分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间) 很多时候我们都需要计算数据库中各个表的数据量和每行记录所占用空间 这里共享一个脚本 CREATE TABLE #tab ...

随机推荐

  1. flex中form表单中子元素之间的距离控制

    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.ado ...

  2. iOS之NSDictionary和NSArray以及NSMutableDictionary和NSMutableArray:将不再是问题

    字典的key就相当于数组的下标,怎样操作数组你就学会了怎样才做字典:来感受一把 需要注意的是读取文件的类型要集合.plist文件的rooty:否则将不能读入文件 // 1.全国省市:得到的是省和市 / ...

  3. hbuilder 手机app开发系列(一)

    最佳答案好水啊,实在看不过眼,首先apicloud是一个框架,hbuidler是ide工具,两者没什么可比性.我来推荐一个国外免费开源的项目吧,Ionic framework,我之所以推荐它是因为它支 ...

  4. ArcGIS 10.5,打造智能的Web GIS平台

    2017年新年来临之际,ArcGIS 10.5正式发布.历经几个版本,ArcGIS 10.5已经革新为一个智能的以Web为中心的地理平台,推出更精细的分级授权.全新的i3S三维标准.大数据分析处理产品 ...

  5. Scala中function的理解

    在函数式语言中,函数是和value一样地位的一等公民,他可以作为变量,或者作为参数传递给另一个函数 ##作为变量 val f=(x:Int)=>x+1 为啥可以这样写? 由于scala是OOP, ...

  6. laravel定时任务

    原文链接:https://github.com/liebig/cron 感觉Cron只是帮你将很多需要定时执行的任务都归结在一个方法中,并且各自设定不同的时间,比较统一方便,但是在外部还是需要操作li ...

  7. 测试部署nginx

    1.已经安装了nginx 2.修改tomcat端口号为10081(可随意) 3 修改nginx的nginx.config  如下: upstream apiserver {           ip_ ...

  8. 用74HC165读8个按键状态(转)

    源:用74HC165读8个按键状态 //-------------------------------------------------------------------------- //来源: ...

  9. iOS开发笔记 - 界面调试神器Reveal

    http://blog.csdn.net/jackfrued/article/details/50934092     Reveal是iOS开发工具中的神器之一,它能够在应用程序运行过程中调试应用程序 ...

  10. UVa 412 - Pi

    题目大意:给定一种估算Pi的方法:给出一系列随机数,从中任选两个数,这两个数的最大公约数不大于1(互质)的概率为6/(Pi*Pi),然后给出一系列数,据此估算Pi的值.直接模拟就好了. #includ ...