题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5878

题意:找到第一个>=n的数x, 满足 x = 2a3b5c7d;n<=1e9;

打表找到10e9以内的所有符合条件的数,然后二分找到即可;

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define met(a, b) memset(a, b, sizeof(a))
#define N 100005
#define INF 0x3f3f3f3f
typedef long long LL;
const LL MAX = 1e9+; int cnt = ;
LL f[N], a2[], a3[], a5[], a7[]; void Init()
{
int P, Q, I, J;
a2[] = a3[] = a5[] = a7[] = ; for(int i=; a2[i-]*<=MAX; i++, I=i) a2[i] = a2[i-]*;
for(int i=; a3[i-]*<=MAX; i++, J=i) a3[i] = a3[i-]*;
for(int i=; a5[i-]*<=MAX; i++, P=i) a5[i] = a5[i-]*;
for(int i=; a7[i-]*<=MAX; i++, Q=i) a7[i] = a7[i-]*; for(int i=; i<I; i++)
{
for(int j=; j<J; j++)
if(MAX/a2[i] >= a3[j])
for(int p=; p<P; p++)
if(MAX/(a2[i]*a3[j]) >= a5[p])
for(int q=; q<Q; q++)
{
if(MAX/(a2[i]*a3[j]*a5[p]) >= a7[q])
f[cnt++] = a2[i]*a3[j]*a5[p]*a7[q];
}
}
sort(f, f+cnt);
} int main()
{
Init(); int T; LL n;
scanf("%d", &T);
while(T--)
{
scanf("%I64d", &n);
int pos = upper_bound(f, f+cnt, n) - f;
if(f[pos-] == n) pos--;
printf("%I64d\n", f[pos]);
}
return ;
}

I Count Two Three---hdu5878(打表+二分)的更多相关文章

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

  2. HDU - 5878 2016青岛网络赛 I Count Two Three(打表+二分)

    I Count Two Three 31.1% 1000ms 32768K   I will show you the most popular board game in the Shanghai ...

  3. HDU 5878 I Count Two Three (打表+二分查找) -2016 ICPC 青岛赛区网络赛

    题目链接 题意:给定一个数n,求大于n的第一个只包含2357四个因子的数(但是不能不包含其中任意一种),求这个数. 题解:打表+二分即可. #include <iostream> #inc ...

  4. 「ZJOI2018」胖(ST表+二分)

    「ZJOI2018」胖(ST表+二分) 不开 \(O_2\) 又没卡过去是种怎么体验... 这可能是 \(ZJOI2018\) 最简单的一题了...我都能 \(A\)... 首先我们发现这个奇怪的图每 ...

  5. I Count Two Three(打表+排序+二分查找)

    I Count Two Three 二分查找用lower_bound 这道题用cin,cout会超时... AC代码: /* */ # include <iostream> # inclu ...

  6. [LeetCode] #1# Two Sum : 数组/哈希表/二分查找/双指针

    一. 题目 1. Two SumTotal Accepted: 241484 Total Submissions: 1005339 Difficulty: Easy Given an array of ...

  7. HDU5878(打表)

    I Count Two Three Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  8. GCD(st表+二分)

    GCD Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submis ...

  9. 【BZOJ-4310】跳蚤 后缀数组 + ST表 + 二分

    4310: 跳蚤 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 180  Solved: 83[Submit][Status][Discuss] De ...

随机推荐

  1. 更新Android SDK之后Eclipse提示ADT版本过低的一个简易解决办法

    首先说明一下发表这一篇博文的“历史原因”吧,因为在更新SDK之后,进入Eclipse设置Android SDK目录的时候,会突然说我的版本低什么的,尝试自己解决但失败之后,我在搜索引擎上找了很多中文的 ...

  2. 【BZOJ】3673: 可持久化并查集 by zky & 3674: 可持久化并查集加强版(可持久化线段树)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3674 http://www.lydsy.com/JudgeOnline/problem.php?id ...

  3. 【wikioi】1108 方块游戏(模拟)

    http://wikioi.com/problem/1108/ 这题有点变态,因为他根本没有策略! 还是说这题不是实时的?反正这题很变态,是在一个时间段同时消除所有的行列斜边,同一时间!!!!!! 所 ...

  4. FireFox火狐浏览器与IE兼容问题 - 透明滤镜 DIV滚动条

    问题一:最简单的鼠标移过手变型的css要改了 cursor:pointer;/*FireFox(火狐)不支持cursor:hand*/ dw8下面自动出来的也没有hand这个属性了,标准的是point ...

  5. 转:mysql中int、bigint、smallint 和 tinyint的区别与长度的含义

    bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型数据(所有数字).存储大小为 8 个字节. P.S. b ...

  6. winform学习之----进程和线程

    Process[] pros = Process.GetProcesses();//获取多个进程            foreach(var item in pros)            {   ...

  7. Java实现FTP上传下载功能

    Java FTP客户端工具包很多,在此我选用的Apache的FTPClient.这个包的获取可以通过http://commons.apache.org/net/来获取,我使用的是最新的commons- ...

  8. cmd命令行查看windows版本

    1.ver命令不显示sp几 C:\>ver Microsoft Windows XP [Version 5.1.2600] C:\> 08: C:\Users\Administrator& ...

  9. Redis在windows环境下的部署

    一.下载 官网地址:http://redis.io/download Git地址:https://github.com/MSOpenTech/redis 注:官方无windows版本,需要window ...

  10. {转自MC}NVIDIA DirectX 11演示DEMO详解

    http://tieba.baidu.com/p/1960826986 图形技术无论如何发展,最终都要落到实际的应用中才有效果.在个人电脑上,图形技术最大的用户除了显示UI和操作界面外,就是呈现美轮美 ...