题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010

题意:中文题诶~

思路:求第一个比 x (1<=x<=1e18)大或者等于的数y, 且y的因子只有2, 3, 5,即y=pow(2, i)*pow(3, j)*pow(5, k);

那么显然我们可以通过枚举i, j, k求出所有由2, 3, 5因子构成的数,并将其存入数组中,再二分查找数组中第一个大于等于x的数即为答案;

代码:

 #include <bits/stdc++.h>
#define ll long long
#define MAXN 100000
using namespace std; ll a[MAXN];
const ll inf=1e18; ll get_pow(ll x, int n){
ll ans=;
while(n){
if(n&){
ans*=x;
}
x*=x;
n>>=;
}
return ans;
} void geloutingyu(void){ //**注意不能直接用pow(),会有精度问题
int pos=;
for(ll i=; get_pow(, i)<=inf; i++){
for(ll j=; get_pow(, i)*get_pow(, j)<=inf; j++){
for(ll k=; get_pow(, i)*get_pow(, j)*get_pow(, k)<=inf; k++){
a[pos++]=get_pow(, i)*get_pow(, j)*get_pow(, k);
}
}
}
} int main(void){
int t;
ll x;
geloutingyu();
sort(a, a+MAXN);
cin >> t;
while(t--){
cin >> x;
if(x==){
cout << << endl;
continue;
}
int pos=lower_bound(a, a+MAXN, x)-a;
cout << a[pos] << endl;
}
return ;
}

51nod1010(枚举+二分)的更多相关文章

  1. HDU4430 Yukari's Birthday(枚举+二分)

    Yukari's Birthday  HDU4430 就是枚举+二分: 注意处理怎样判断溢出...(因为题目只要10^12) 先前还以为要用到快速幂和等比数列的快速求和(但肯定会超__int64) 而 ...

  2. CSU OJ PID=1514: Packs 超大背包问题,折半枚举+二分查找。

    1514: Packs Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 61  Solved: 4[Submit][Status][Web Board] ...

  3. 4 Values whose Sum is 0(枚举+二分)

    The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute ...

  4. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分

    C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is p ...

  5. HDU 4282 A very hard mathematic problem --枚举+二分(或不加)

    题意:问方程X^Z + Y^Z + XYZ = K (X<Y,Z>1)有多少个正整数解 (K<2^31) 解法:看K不大,而且不难看出 Z<=30, X<=sqrt(K) ...

  6. Subset---poj3977(折半枚举+二分查找)

    题目链接:http://poj.org/problem?id=3977 给你n个数,找到一个子集,使得这个子集的和的绝对值是最小的,如果有多种情况,输出子集个数最少的: n<=35,|a[i]| ...

  7. hdu 5288 OO’s Sequence 枚举+二分

    Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number o ...

  8. codeforces 613B B. Skills(枚举+二分+贪心)

    题目链接: B. Skills time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  9. Codeforces gym101612 L.Little Difference(枚举+二分)

    传送:http://codeforces.com/gym/101612 题意:给定一个数n(<=1e18),将n分解为若干个数的成绩.要求这些数两两之间的差值不能大于1. 分析: 若n==2^k ...

随机推荐

  1. invalid constant type: 18

    javassist 3.18以下的版本不支持在JDK1.8下运行

  2. linux命令学习笔记(50):crontab命令

    前一天学习了 at 命令是针对仅运行一次的任务,循环运行的例行性计划任务,linux系统则是由 cron (crond) 这个系统服务来控制的.Linux 系统上面原本就有非常多的计划性工作,因此这个 ...

  3. 【leetcode刷题笔记】Search a 2D Matrix

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  4. 20179203 《Linux内核原理与分析》第十周作业

    第17章 设备与模块 一.设备类型 1. Linux及Unix系统: 块设备 字符设备 网络设备 2.块设备: 通常缩写为blkdev,它是可寻址的,寻址以块为单位,块大小随设备不同而不同:块设备通常 ...

  5. POJ3417Network

    Network Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5311   Accepted: 1523 Descripti ...

  6. cmd命令,输出为txt文本

    在命令行后面,加上'-t > d:output.txt'. 具体可参考如下图: //=====补充===== 所以,在调试nodejs的时候,如果用命令行调试,则可把输出信息都重定向到一个文件中 ...

  7. BZOJ1345:[Baltic2007]序列问题

    浅谈栈:https://www.cnblogs.com/AKMer/p/10278222.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php?id ...

  8. oracle rac搭建

    (一)环境准备 主机操作系统 windows10 虚拟机平台 vmware workstation 12 虚拟机操作系统 redhat 5.5 x86(32位) :Linux.5.5.for.x86. ...

  9. iPhone白苹果怎么办?白苹果各种解决办法方法

    iPhone白苹果怎么办?白苹果各种解决办法方法 日期:2014-07-16 来源:爱思助手 浏览次数:60962 越狱后大家也疯狂的装入各种插件,由于一些插件会产生冲突,造成白苹果现象,无法进入手机 ...

  10. ngx通讯之可观察对象实现

    1.公共服务 //test.service.ts import {Injectable} from '@angular/core'; import {Subject} from 'rxjs/Subje ...