I Count Two Three

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

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
 
题意: t组数据 给你一个n  输出不小于n的最短的数x
x=2^a*3^b*5^c*7^d
题解:因为最大为1e9  先打表找到所有的满足条件的数x 之后二分答案
 /******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#define ll long long
#define mod 1000000007
#define PI acos(-1.0)
#define N 1000000000
using namespace std;
int t;
ll a2[]={},a3[]={},a5[]={},a7[]={};
int jishu;
ll ans[];
void init()
{
jishu=;
int er=,san=,wu=,qi=;
for(int i=; a2[i-]<=N;er++,i++)
a2[i]=a2[i-]*;
for(int i=; a3[i-]<=N;san++,i++)
a3[i]=a3[i-]*;
for(int i=; a5[i-]<=N;wu++,i++)
a5[i]=a5[i-]*;
for(int i=; a7[i-]<=N;qi++, i++)
a7[i]=a7[i-]*;
for(int i=; i<er; i++)
for(int j=; a2[i]*a3[j]<=N&&j<san; j++)
for(int k=; a2[i]*a3[j]*a5[k]<=N&&k<wu; k++)
for(int l=; a2[i]*a3[j]*a5[k]*a7[l]<=N&&l<qi; l++)
ans[jishu++]=a2[i]*a3[j]*a5[k]*a7[l];
sort(ans,ans+jishu);
}
int main()
{
int n;
while(scanf("%d",&t)!=EOF)
{
init();
for(int i=; i<=t; i++)
{
scanf("%d",&n);
printf("%I64d\n",ans[lower_bound(ans,ans+jishu,n)-ans]);
}
}
return ;
}
 

2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分的更多相关文章

  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 I Count Two Three

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...

  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. 数学--数论--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 ...

  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. POJ 1753 Flip Game 状态压缩,暴力 难度:1

    Flip Game Time Limit: 1000MS  Memory Limit: 65536K  Total Submissions: 4863  Accepted: 1983 Descript ...

  2. 向MySql中插入中文时出现乱码

    这个因为字符集编码问题.在连接字符串中加上CharSet=gbk

  3. sql alter表字段处理

    --添加字段 ALTER table WCOLLECTION add CLT_ID int null default(0) --将已有字段类型为 NULL 修改为 NOT NULLalter tabl ...

  4. IE9的css hack

    以前写过<IE8的css hack>,ie9一出css hack也该更新,以前一直没关注,今天在内部参考群mxclion分享了IE9的css hack,拿出来也分享一下: select { ...

  5. (三)获取iphone的IMSI

    今天的任务是 iPhone上怎样获取 imsi 信息 来判断所属运营商,资料找了很久!总体有两种方案,但是其中一种好像不行 这里我都记录下来吧: 1: 这是使用coreTelephony.framew ...

  6. Coudera-Manager/CDH的安装和部署

    由于之前部署的集群采用的是用apache hadoop的方式来实现,但是考虑到运维的成本问题,下面将apache hadoop转换成cloudera cdh.下面主要讲解一下cloudera cdh的 ...

  7. NSString的几种常用方法

    NSString的几种常用方法   要把 “2011-11-29” 改写成 “2011/11/29”一开始想用ios的时间格式,后来用NSString的方法搞定. [string stringByRe ...

  8. NorFlash和NandFlash区别

      Flash编程原理都是只能将1写为0,而不能将0写成1.所以在Flash编程之前,必须将对应的块擦除,而擦除的过程就是将所有位都写为1的过程,块内的所有字节变为0xFF.因此可以说,编程是将相应位 ...

  9. Android Toast效果

    Android Toast效果是一种提醒方式,在程序中使用一些短小的信息通知用户,过一会儿会自动消失,实现如下: FirstActivity.java package org.elvalad.acti ...

  10. Python入门(四,高级)

    一,面向对象 面向对象技术简介 类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例. 类变量:类变量在整个实例化的对象中是公用的. ...