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. [数据结构]Treap简介

    [写在前面的话] 如果想学Treap,请先了解BST和BST的旋转 二叉搜索树(BST)(百度百科):[here] 英文好的读者可以戳这里(维基百科) 自己的博客:关于旋转(很水,顶多就算是了解怎么旋 ...

  2. NIPS 2016论文:英特尔中国研究院在神经网络压缩算法上的最新成果

    NIPS 2016论文:英特尔中国研究院在神经网络压缩算法上的最新成果 http://www.leiphone.com/news/201609/OzDFhW8CX4YWt369.html 英特尔中国研 ...

  3. ios中操作技巧

    1.配置字段快捷键: @property(nonatimic,copy) NSString *<#param#>; 2.NSNumber 转NSString 最快简单方式: NSNumbe ...

  4. log4CXX第二篇---配置文件(properties文件)详解

    一.Log4j简介 Log4j有三个主要的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志以何种形式输出.综合使 ...

  5. MySQL常用命令总结3

    id SMALLINT UNSIGNED [AUTO_INCREMENT] PRIMARY KEY, //把id定义为主键且自动排号,每张数据表只有一个主键,不能为NULL,确保记录唯一性 //省略a ...

  6. Undefined symbols for architecture i386: "_crc32", referenced from:——crc链接错误

    有时候用别人的框架,你会碰到下面的错误,很是吓人,什么玩意,我怎么看不懂!!! Undefined symbols for architecture i386:  "_RELEASE&quo ...

  7. Delphi 数据类型的说明

    简单类型包括实数类型(Real) 和有序类型(Ordinal),有序类型又包括整数类型,字符类型,布尔类型,枚举类型和子界类型等. 数据类型                       范围      ...

  8. 异常捕获拒绝闪退 让应用从容的崩溃UncaughtExceptionHandler

    虽然大家都不愿意看到程序崩溃,但可能崩溃是每个应用必须面对的现实,既然崩溃已经发生,无法阻挡了,那我们就让它崩也崩得淡定点吧. IOS SDK中提供了一个现成的函数 NSSetUncaughtExce ...

  9. X-005 FriendlyARM tiny4412 uboot移植之时钟初始化

    <<<<<<<<<<<<<<<<<<<<<<<<< ...

  10. nodejs nodemailer中间件

    var stransporter = nodemailer.createTransport({ host:smtp-163.com', //适合163 secureConnection: true, ...