打表+二分

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL inf=1e18+100;
LL a[20000];
int num;
void init()
{
num=0;
LL i,j,z;
for(i=1;i<inf;i=i*2){
for(j=1;j*i<inf;j=j*3){
for(z=1;i*j*z<inf;z=z*5){
a[num++]=i*j*z;
}
}
}
sort(a+1,a+num);
}
int main()
{
init();
int T;
scanf("%d",&T);
while(T--)
{
LL n;
scanf("%lld",&n);
int left=1,right=num-1;
while(left<right)
{
int mid=left+(right-left)/2;
if(a[mid]>=n)
right=mid;
else
left=mid+1;
}
printf("%lld\n",a[left]);
}
return 0;
}

51nod1010【二分】的更多相关文章

  1. 51nod1010(枚举+二分)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010 题意:中文题诶- 思路:求第一个比 x (1<= ...

  2. BZOJ1012: [JSOI2008]最大数maxnumber [线段树 | 单调栈+二分]

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 8748  Solved: 3835[Submi ...

  3. BZOJ 2756: [SCOI2012]奇怪的游戏 [最大流 二分]

    2756: [SCOI2012]奇怪的游戏 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 3352  Solved: 919[Submit][Stat ...

  4. 整体二分QAQ

    POJ 2104 K-th Number 时空隧道 题意: 给出一个序列,每次查询区间第k小 分析: 整体二分入门题? 代码: #include<algorithm> #include&l ...

  5. [bzoj2653][middle] (二分 + 主席树)

    Description 一个长度为n的序列a,设其排过序之后为b,其中位数定义为b[n/2],其中a,b从0开始标号,除法取下整. 给你一个长度为n的序列s. 回答Q个这样的询问:s的左端点在[a,b ...

  6. [LeetCode] Closest Binary Search Tree Value II 最近的二分搜索树的值之二

    Given a non-empty binary search tree and a target value, find k values in the BST that are closest t ...

  7. [LeetCode] Closest Binary Search Tree Value 最近的二分搜索树的值

    Given a non-empty binary search tree and a target value, find the value in the BST that is closest t ...

  8. jvascript 顺序查找和二分查找法

    第一种:顺序查找法 中心思想:和数组中的值逐个比对! /* * 参数说明: * array:传入数组 * findVal:传入需要查找的数 */ function Orderseach(array,f ...

  9. BZOJ 1305: [CQOI2009]dance跳舞 二分+最大流

    1305: [CQOI2009]dance跳舞 Description 一次舞会有n个男孩和n个女孩.每首曲子开始时,所有男孩和女孩恰好配成n对跳交谊舞.每个男孩都不会和同一个女孩跳两首(或更多)舞曲 ...

随机推荐

  1. Struts MVC工作原理(转载)

    1.Struts MVC中Model 1 和Model 2简介 我们在开发Web应用时经常提到的一个概念是Model 1/Model 2,那么到底它是什么意思呢?其实它是对采用JSP技术构成Web应用 ...

  2. LookAround开元之旅

    http://blog.csdn.net/lancees/article/details/17696805

  3. ZOJ 3551 Bloodsucker <概率DP>

    题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3551 题意:开始有N-1个人和一个吸血鬼, 每天有两个生物见面,当人 ...

  4. gitlab 外网 无法访问 查端口 看文档

    云服务器安装成功后 curl   页面可以正常跳转 重置密码的token  页面可以生成 但是  外网无法 访问 [root@test ~]# curl 127.0.0.1:18021 <htm ...

  5. Struts页面跳转问题

    只有在web-INF中的jsp才可以不用加namespace名 <s:a action="systemIndexAction_turn" >跳转</s:a> ...

  6. jmeter之java请求

    通常情况下,推荐使用jmeter之java请求编写一beashell调用java代码(上篇)(推荐)编写Java 请求 有以下优势 脚本易维护 易调试 开发脚本周期短 不过网上扩展java请求文章比较 ...

  7. leetcode 792. Number of Matching Subsequences

    Given string S and a dictionary of words words, find the number of words[i] that is a subsequence of ...

  8. Codeforces Round #374 (Div. 2) D. Maxim and Array —— 贪心

    题目链接:http://codeforces.com/problemset/problem/721/D D. Maxim and Array time limit per test 2 seconds ...

  9. maven项目所遇到的问题解决

    1.在Eclipse中创建Maven的Web项目时出现错误:An internal error occurred during: "Retrieving archetypes:". ...

  10. hdu 1236 排名(排序)

    题意:按成绩排序 思路:排序 #include<iostream> #include<stdio.h> #include<string.h> #include< ...