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. 找出html中的图片、包括css中的图片,读出图片数据转换为base64数据

    <?php echo ">> 图片的地址,css里面的要打单引号\r\n"; echo ">> 相同的图片,使用css实现图片地址只出现一次 ...

  2. 4通用Makefile编写

    a.c #include<stdio.h> #include "a.h" int main() { printf("hello world\n"); ...

  3. ActiveX 技术疑点 一

    1.编写基于MFC Activex 使用 静态库 .lib , MFC 的使用 在静态库中使用MFC . 生成ocx 文件 注册失败.提示: ***还是一个可执行文件,没有为这个文件类型注册的注册帮助 ...

  4. outlook新邮件到达提醒设置以及outlook最小化到托盘设置

    有些邮件是需要马上处理的,因此希望能在收到邮件之后马上就知道,但是有不希望频繁的去检查有没有.outlook可以帮我们轻松做到新邮件到达提醒. 一 .设置outlook新邮件到达提醒:选项->电 ...

  5. UITextView添加一个placeholder功能

    控件UITextField有个placeholder属性,UITextField和UITextView使用方法基本类似,有两个小区别:1.UITextField单行输入,而UITextView可以多行 ...

  6. ios 学习 广告图片轮播器

    // // ViewController.m // 图片轮播器 // // Created by zjj on 15/5/23. // Copyright (c) 2015年 zjj. All rig ...

  7. OpenCV之响应鼠标(二):函数cvSetMouseCallback()和其副程式onMouse()的使用(OpenCV2.4.5)

    每當滑鼠在視訊視窗介面點擊一下的時候,都會有固定三個動作 1.點擊(Click) 2.放開(Down)3.滑動(move) 因此,程式執行滑鼠在點擊的時候onMouse()都會連續跑三次,代表滑鼠在點 ...

  8. [流媒体]VLC主要模块

    libvlccore vlcthread: vlc线程是libvlccore的重要组成部分,我们在src文件夹下面android.os2.posix.win32等文件夹下包含thread.c文件,说明 ...

  9. [windows驱动]windows8.1驱动调试前戏

    人们都说在干正事之前,得先做足前戏才会爽,我一直很认同这个观点,下面我来总结下进行windows8.1的WDK调试所要做的准备工作. 软件安装: 1.VS2013. 2.WDK8.1 3.Window ...

  10. IOS开发中--点击imageView上的Button没有任何反应

    点击imageView上的Button没有任何反应:    解决方法:设置图片的userInteractionEnabled为YES,使该imageView可以与用户进行交互