hdu5878 2016青岛网络赛-打表+二分
2016-09-17 20:10
411 查看
I Count Two Three
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 167 Accepted Submission(s): 96
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
Source
2016 ACM/ICPC Asia Regional Qingdao Online
Recommend
青岛网络赛
题意:给一个数x,求数y使得y的因子只有2 3 5 7 ,并且y要大于x,求最小的满足题意的y;
这个题打表,把以 2 3 5 7 为因子的数打出来然后排序,每次二分查找大于x 的数即可
AC代码:
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <set>
#include <math.h>
using namespace std;
const int maxn=1e6+100,up=1e9+1;
typedef long long LL;
LL a[maxn];
int main()
{
int m=32;
int tot=0;
for(int i=0;i<=m;i++)
{
if(pow(2,i)>=up)
break;
for(int j=0;j<=m;j++)
{
if(pow(2,i)*pow(3,j)>=up)
break;
for(int k=0;k<=m;k++)
{
if(pow(2,i)*pow(3,j)*pow(5,k)>=up)
break;
for(int l=0;l<=m;l++)
{
if(pow(2,i)*pow(3,j)*pow(5,k)*pow(7,l)>=up)
break;
a[tot++]=pow(2,i)*pow(3,j)*pow(5,k)*pow(7,l);
}
}
}
}
sort(a,a+tot);
LL n,x;
while(scanf("%lld",&n)!=-1)
{
while(n--)
{
scanf("%lld",&x);
printf("%lld\n",a[lower_bound(a,a+tot,x)-a]);
}
}
return 0;
}
相关文章推荐
- C/S模型 多线程服务器实现简单计算工作并回馈客户端
- hdu5889 最短路+网络流
- ArcEngine新建几何网络_GeometricNetwork
- Servlet之HttpServletResponse和HttpServletRequest
- 网络流一·Ford-Fulkerson算法
- 断点续传学习心得与体会
- 第二十八篇、自定义的UITableViewCell上有图片需要显示,要求网络网络状态为WiFi时,显示图片高清图;网络状态为蜂窝移动网络时,显示图片缩略图
- 转:借助Stetho在Chrome上调试Android网络&数据库
- 网络连接问题
- HTTP 协议入门
- UNIX网络编程中的需要注意的问题
- 2016ICPC青岛网络赛 1006
- HUD 5883 The Best Path(2016亚洲区青岛站网络赛)
- 2016 ICPC 青岛网络赛 1005
- HDU 5882 Balanced Game(2016亚洲区青岛站网络赛)
- 2016ICPC青岛网络赛 1011
- 2016ICPC青岛赛区网络赛 1004
- 2016ICPC青岛赛区网络赛 1002
- HDU 5878 I Count Two Three(2016亚洲区青岛站网络赛)
- 2016ICPC青岛赛区网络赛 1001