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

这个题的意思是让你找到一个k大于n并且能写成2a3b5c7d2^a3^b5^c7^d2a3b5c7d这种形式。

然后就先把能写成这种形式的数的全部处理出来,在进行二分查找,比这个大的最小的数。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long a[200000];
int d = 0;
int main()
{
int x, y;
d = 0;
memset(a, 0, sizeof(a));
for (int i = 0; i <= 32; i++) {
for (int j = 0; j <= 19; j++) {
for (int k = 0; k <= 12; k++) {
for (int h = 0; h <= 11; h++) {
long long s = pow(2, i) * pow(3, j) * pow(5, k) * pow(7, h);
if (s > 1000000000 || s < 0)
break;
else
{
a[d++] = s;
}
}
}
}
}
sort(a, a + d);
scanf("%d", &x);
while (x--)
{
scanf("%d", &y);
printf("%lld\n", *lower_bound(a, a + d, y));
}
return 0;
}

数学--数论--HDU--5878 Count Two Three 2016 ACM/ICPC Asia Regional Qingdao Online 1001的更多相关文章

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

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

  4. 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( ...

  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】

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

  9. Hdu OJ 5884-Sort (2016 ACM/ICPC Asia Regional Qingdao Online)(二分+优化哈夫曼)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5884 题目大意:有n个有序的序列,对于第i个序列有ai个元素. 现在有一个程序每次能够归并k个序列, ...

随机推荐

  1. 2018蓝桥杯省赛(C/C++ C组)

    因进考场不让带优盘,顾想不起有些啥题了,静待更新吧! 再次强调C++最新标准,main函数必须指定返回类型为int,且返回值最好为0(人走的多了就是路了,有人偏返回999那也没办法) 1.大概是小明给 ...

  2. 白话说编程之java线程

    线程和进程: 在说多线程之前,我们先来研究一下线程,说到线程,我们又不得不说到进程,因为很多初学者会把线程和进程分不清,搞混淆. 进程: 是操作系统系统运行的最小单元.怎么理解这句话,可以这样去对比, ...

  3. 17-jmeter相关插件介绍

    转--https://www.cnblogs.com/imyalost/p/7751981.html

  4. ES6构造函数class 和 ES5构造函数语法

    构造函数就是JavaScript程序定义好的函数,我们直接使用就可以,实际也是一种函数,构造函数专门用于生成定义对象,通过构造函数生成的对象,称为实例化对象 构造函数分为两种,一种是JavaScrip ...

  5. 利用numpy实现多维数组操作图片

    1.上次介绍了一点点numpy的操作,今天我们来介绍它如何用多维数组操作图片,这之前我们要了解一下色彩是由blue ,green ,red 三种颜色混合而成,0:表示黑色 ,127:灰色 ,255:白 ...

  6. stand up meeting 1/18/2016

    part 组员                工作              工作耗时/h 明日计划 工作耗时/h    UI 冯晓云  准备最后的发布和整个开发的整理总结    6 release ...

  7. Eureka源码分析

    源码流程图 先上图,不太清晰,抱歉 一.Eureka Server源码分析 从@EnableEurekaServer注解为入口,它是一个标记注解,点进去看 注解内容如下 /** * 激活Eureka服 ...

  8. python白帽子/黑客/实战编程教程

    Python搜索爬虫抓取超高清视频教程_第一期Python搜索爬虫抓取超高清视频教程_第二期Python搜索爬虫抓取视频教程_第三期Python搜索爬虫抓取视频教程_第四期Python搜索引擎爬虫抓取 ...

  9. Mark down 使用总结

    Markdown语法 Markdown是一种纯文本.轻量级的标记语言,通过简单的标记,就可以使文本具有一定的格式,操作简单.使用广泛,常见的比如github上的README.md . Markdown ...

  10. Python神库分享之geoip2 IP定位库

    先安装这两个 pip install python-geoip-geolite2 -i https://pypi.douban.com/simple pip install geoip2 然后下载资源 ...