给一个数n,让你求一个大于等于n的最小的满足题意中2^a*3^b*5^c*7^d的数字。

思路:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
int T;
ll anw[];
ll Pow(int x,int num){
ll ans=1LL;
for(int i=;i<=num;i++) ans=ans*1LL*x;
return ans;
}
ll n;
int main(){
int cnt=;
for(int i=;i<=;i++){
for(int j=;j<=;j++){
for(int k=;k<=;k++){
for(int l=;l<=;l++){
ll tmp=Pow(,i)*Pow(,j);
if(tmp>1e9) break;
tmp*=Pow(,k);
if(tmp>1e9) break;
tmp*=Pow(,l);
if(tmp>1e9) break;
anw[++cnt]=tmp;
}
}
}
}
sort(anw+,anw+cnt+);
scanf("%d",&T);
while(T--){
scanf("%I64d",&n);
int x=lower_bound(anw+,anw+cnt+,n)-anw;
printf("%I64d\n",anw[x]);
}
return ;
}

HDU 5878---预处理+二分查找的更多相关文章

  1. HDU 5878 I Count Two Three (预处理+二分查找)

    题意:给出一个整数nnn, 找出一个大于等于nnn的最小整数mmm, 使得mmm可以表示为2a3b5c7d2^a3^b5^c7^d2​a​​3​b​​5​c​​7​d​​. 析:预处理出所有形为2a3 ...

  2. Can you find it? HDU - 2141 (二分查找)

    Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate ...

  3. HDU 1969 Pie(二分查找)

    Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...

  4. (step4.1.2)hdu 1969(Pie——二分查找)

    题目大意:n块馅饼分给m+1个人,每个人的馅饼必须是整块的,不能拼接,求最大的. 解题思路: 1)用总饼的体积除以总人数,得到每个人最大可以得到的V.但是每个人手中不能有两片或多片拼成的一块饼. 代码 ...

  5. HDU 2578(二分查找)

    686MS #include <iostream> #include <cstdlib> #include <cstdio> #include <algori ...

  6. HDU 5288 OO&#39;s sequence (2015多校第一场 二分查找)

    OO's Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  7. hdu 2141:Can you find it?(数据结构,二分查找)

    Can you find it? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others ...

  8. hdu 2141 Can you find it?(二分查找)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2141 题目大意:查找是否又满足条件的x值. 这里简单介绍一个小算法,二分查找. /* x^2+6*x- ...

  9. HDU 4614 线段树+二分查找

    Vases and Flowers 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4614 Problem Description Alice is s ...

随机推荐

  1. WPF DateTimePicker 和 TimeSpanPicker 控件发布

    原文:WPF DateTimePicker 和 TimeSpanPicker 控件发布 根据http://datetimepickerwpf.codeplex.com/ 这个项目重构了一下代码设计了我 ...

  2. 在WPF中自定义控件(3) CustomControl (下)

    原文:在WPF中自定义控件(3) CustomControl (下)   在WPF中自定义控件(3) CustomControl (下)                                 ...

  3. Mysql数据库的压力

    rationalError: (2006, 'MySQL server has gone away') 2017年10月10日 20:04:43 阅读数:377 问题描述 使用django+celer ...

  4. hdu4742 Pinball Game 3D

    真他娘的搞不懂cdq分治的顺序问题.但是candy?的博客里提到过,多想想吧-- #include <algorithm> #include <iostream> #inclu ...

  5. Delphi实例之一个简易的浏览器的实现

    Delphi实例之一个简易的浏览器的实现 Delphi7的WebBrowser组件提供了很多不错的网页设计的功能,下面做一个简单的浏览器.组件很简单按照下面摆放就行了. 这是运行后的效果 源代码 主页 ...

  6. python 字典(dict)按键和值排序

    python 字典(dict)的特点就是无序的,按照键(key)来提取相应值(value),如果我们需要字典按值排序的话,那可以用下面的方法来进行: 1 下面的是按照value的值从大到小的顺序来排序 ...

  7. Leetcode 679.24点游戏

    24点游戏 你有 4 张写有 1 到 9 数字的牌.你需要判断是否能通过 *,/,+,-,(,) 的运算得到 24. 示例 1: 输入: [4, 1, 8, 7] 输出: True 解释: (8-4) ...

  8. preparedstatement execute()操作成功!但是返回false

    转自http://blog.sina.com.cn/s/blog_963fb3af01013rcs.html Connection con = getConn(); String sql2 = &qu ...

  9. truffle自动化测试脚本

    truffle自动化测试脚本 补充一个unbox 1.部署本地ganache环境 配置文件地址为本地地址 localhost:XXXX 上线的环境为 infura的url 2.命令: truffle ...

  10. java正则表达式 3 -- 查找

    用正则表达式执行查找命令,则需要用正则对象,其规则和执行顺序如下: 指定为字符串的正则表达式必须首先被便以为此类的实例.然后,可将得到的正则对象匹配任意的字符串用于创建Mather对象,执行匹配所涉及 ...