数学--数论--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 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的更多相关文章
- 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^ ...
- 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 ...
- 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( ...
- 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( ...
- 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 ...
- 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 ...
- 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 ...
- 【2016 ACM/ICPC Asia Regional Qingdao Online】
[ HDU 5878 ] I Count Two Three 考虑极端,1e9就是2的30次方,3的17次方,5的12次方,7的10次方. 而且,不超过1e9的乘积不过5000多个,于是预处理出来,然 ...
- Hdu OJ 5884-Sort (2016 ACM/ICPC Asia Regional Qingdao Online)(二分+优化哈夫曼)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5884 题目大意:有n个有序的序列,对于第i个序列有ai个元素. 现在有一个程序每次能够归并k个序列, ...
随机推荐
- 团队项目-运动App
一:团队成员介绍 队长:温学智 博客地址:https://www.cnblogs.com/dazhi151/ 技术型大佬,学习能力相对团队来说是最高的.并且作为班 ...
- django rest framework用户认证
django rest framework用户认证 进入rest framework的Apiview @classmethod def as_view(cls, **initkwargs): &quo ...
- JAVA debug 调试demo
1.设置断点,在代码的行号后面鼠标左键即可2.想要看调用方法的执行流程,那么调用方法也要加断点. package day6_debug; /* * 1.设置断点,在代码的行号后面鼠标左键即可 * 2. ...
- python3(十九)Partial func
# 偏函数(Partial function) # 如int()函数可以把字符串转换为整数,当仅传入字符串时,int()函数默认按十进制转换 # 但int()函数还提供额外的base参数,默认值为10 ...
- Hadoop(二) 单节点案例grep和wordcount|4
前提步骤安装Hadoop,安装步骤: https://www.jianshu.com/p/2ce9775aeb6e 单节点案例官方文档地址:http://hadoop.apache.org/docs/ ...
- 17-jmeter相关插件介绍
转--https://www.cnblogs.com/imyalost/p/7751981.html
- Docker php安装扩展步骤详解
前言 此篇,主要是演示docker-php-source , docker-php-ext-install ,docker-php-enable-docker-configure 这四个命令到底是用来 ...
- Tomcat5启动流程与配置详解
标签:配置 tomcat 休闲 职场 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://zhangjunhd.blog.51cto. ...
- DVWA渗透笔记
Command Injection Low <?php if( isset( $_POST[ 'Submit' ] ) ) { // Get input $target = $_REQUEST[ ...
- Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记(三)之Everything Is an Object
---恢复内容开始--- Both C++ and Java are hybird languages. A hybird language allow multiple programming st ...