题目链接:hdu5878 I Count Two Three

题意:给出一个整数n, 找出一个大于等于n的最小整数m, 使得m可以表示为2^a * 3^b * 5^c * 7^d​​.

题解:打表预处理出所有满足要求的数,排个序然后二分查找解决。

 #include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e9;
ll s[];
ll pow(ll a, ll b){
ll r = ;
while(b){
if(b & )
r *= a;
a *= a;
b >>= ;
}
return r;
}
int cnt;
void init(){
ll i, j, k ,l, t;
cnt = ;
for(i = ; i < ; ++i){
for(j = ; j < ; ++j){
for(k = ;k < ; ++k){
for(l = ; l < ; ++l){
t = pow(, i) * pow(, j);
if(t > 1e9)
break;
t *= pow(, k);
if(t > 1e9)
break;
t *=pow(, l);
if(t > 1e9)
break;
s[cnt++] = t;
}
}
}
}
sort(s, s + cnt);
}
void bi_search(int n){
int l = ,r = cnt - ;
while(l < r){
int mid = l + (r - l)/;
if(s[mid] >= n)
r = mid;
else
l = mid + ;
}
printf("%I64d\n", s[l]);
}
int main(){
int t, n;
scanf("%d", &t);
init();
while(t--){
scanf("%d", &n);
bi_search(n);
}
return ;
}

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

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

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

  2. BZOJ4556:[TJOI\HEOI2016]字符串(后缀数组,主席树,二分,ST表)

    Description 佳媛姐姐过生日的时候,她的小伙伴从某东上买了一个生日礼物.生日礼物放在一个神奇的箱子中.箱子外边写了一个长为n的字符串s,和m个问题.佳媛姐姐必须正确回答这m个问题,才能打开箱 ...

  3. BZOJ3166 [Heoi2013]Alo 【可持久化trie树 + 二分 + ST表】

    题目 Welcome to ALO ( Arithmetic and Logistic Online).这是一个VR MMORPG , 如名字所见,到处充满了数学的谜题. 现在你拥有n颗宝石,每颗宝石 ...

  4. [BZOJ4310] 跳蚤 - 后缀数组,二分,ST表

    [BZOJ4310] 跳蚤 Description 首先,他会把串分成不超过 \(k\) 个子串,然后对于每个子串 \(S\) ,他会从 \(S\) 的所有子串中选择字典序最大的那一个,并在选出来的 ...

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

  6. I Count Two Three---hdu5878(打表+二分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5878 题意:找到第一个>=n的数x, 满足 x = 2a3b5c7d:n<=1e9; 打表 ...

  7. HDU5726 GCD(二分 + ST表)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Give you a sequence of N(N≤100, ...

  8. ZJOI2018 胖 二分 ST表

    原文链接https://www.cnblogs.com/zhouzhendong/p/ZJOI2018Day2T2.html 题目传送门 - BZOJ5308 题目传送门 - LOJ2529 题目传送 ...

  9. BZOJ 5308 [ZJOI2018] Day2T2 胖 | 二分 ST表

    题目链接 LOJ 2529 BZOJ 5308 题解 这么简单的题 为什么考场上我完全想不清楚 = = 对于k个关键点中的每一个关键点\(a\),二分它能一度成为哪些点的最短路起点(显然这些点在一段包 ...

随机推荐

  1. Change An Item Property Using Set_Item_Property In Oracle Forms

    Set_Item_Property is used to change an object's settings at run time. Note that in some cases you ca ...

  2. [HDOJ3308]LCIS(线段树,区间合并)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 题意:给定n个数,两个操作: U A B:将位置A的数值改成B Q A B:查询[A,B]内最长 ...

  3. QLibrary执行load失败

    QLibrary clyy("ledsender.so"); if(!clyy.load());在执行该行代码时会导致程序崩溃. ------------------------- ...

  4. hdu 3934&&poj 2079 (凸包+旋转卡壳+求最大三角形面积)

    链接:http://poj.org/problem?id=2079 Triangle Time Limit: 3000MS   Memory Limit: 30000K Total Submissio ...

  5. 草珊瑚的css基础

    首先要了解如下概念: viewport,窗口大小,containing block,block formatting context,inline formatting context,dirctio ...

  6. chubu

    python解释型语言,不需要编译成机器认可的二进制码,而是直接从源代码运行程序. python是基于c语言开发的. python很容易嵌入到其他语言. 中文注释,必须在前边加上注释说明 : #_*_ ...

  7. mysql 存储过程中limit

    1.mysql的高版本(5.5),存储过程中的limit可以使用变量,如下:select * from student limit iStart,iNum; 2.mysql的低版本(5.1),存储过程 ...

  8. Java后端开发

    Java后端开发 名称 内容 基本框架 Spring.Mybatis Linux服务器   数据库优化   消息服务 rabbitMQ.activeMq rocketMq 缓存服务 memcached ...

  9. Html_在线客服静态网页

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. 如何使用 declare-styleable

    如何使用 declare-styleable 在创建 xml 到 objectName/res/values/ 命名为 attrs.xml 编辑文件内容为(示例)<?xml version=&q ...