题目链接: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. BZOJ3118 : Orz the MST

    对于树边显然只需要减少权值,对于非树边显然只需要增加权值 设i不为树边,j为树边 X[i]:i增加量 X[j]:j减少量 C[i]:修改1单位i的代价 对于每条非树边i(u,v),在树上u到v路径上的 ...

  2. 关于 List<T>

    System.Object   System.Collections.Generic.List<T>   list<string,string>,这种形式本身就是错误的,你可以 ...

  3. 学习了ZKW费用流

    所谓ZKW费用流,其实就是Dinic. 若干年前有一个人发明了最小增广路算法,每次用BFS找一条增广路,时间O(nm^2) 然后被DinicD飞了:我们为什么不可以在长度不变时多路增广呢?时间O(n^ ...

  4. 清除 WD MyCloud 自动生成的 .wdmc 目录

    1. 先 SSH,停止相应服务 /etc/init.d/wdmcserverd stop/etc/init.d/wdphotodbmergerd stop 2. 禁止服务自启动 update-rc.d ...

  5. 产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复

    产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复 用一个ArrayList存储1到100然后随机产生0到arraylist.size()之间的数字作为下标然后从arrayli ...

  6. jQuery Mobile高手必备的十大技巧和代码片段

    与任何新技术一样,常常难就难在如何开始入手. 有鉴于此,我们整理出了与jQuery Mobile库有关的我认为最便利的一些技巧.方法和代码片段. 由于本文不是旨在全面介绍使用jQuery Mobile ...

  7. 关于HTML条件注释你可能不知道的一些事儿

    最近经常看到类似这样的HTML代码片段,很多前端开发人员应该都熟悉: 1 <!--[if lt IE 7]>      <html class="ie6"> ...

  8. JavaScript - 倒计时

    http://www.helloweba.com/demo/loading/ WEB开发中经常会用到倒计时来限制用户对表单的操作,比如希望用户在一定时间内看完相关协议信息才允许用户继续下一步操作,又比 ...

  9. C# - 杨涛分页控件AspNetPager

    http://www.webdiyer.com/downloads/ 前台 <%@ Page Language="C#" AutoEventWireup="true ...

  10. [转]asp.net mvc 从数据库中读取图片

    本文转自:http://www.cnblogs.com/mayt/archive/2010/05/20/1740358.html 首先是创建一个类,继承于ActionResult,记住要引用Syste ...