51Nod 1010 只包含因子2 3 5的数 打表+二分
2017-11-28 20:49
204 查看
这题想到了打表+二分
结果打表让我玩了半个小时没弄出来
刚开始一直是将求出来的三个数相加(是乘啊啊 啊啊)
然后自己想到的是用pow()。到现在还不知道哪点错了。
换成普通循环,递乘打表成功。。。
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
const long long INF=1e18;
int main(){
int n;
cin>>n;
vector<long long> vec;
for(long long i=1;i<=INF;i*=2){
for(long long j=1;i*j<=INF;j*=3){
for(long long k=1;i*j*k<=INF;k*=5){
vec.push_back(i*j*k);
}
}
}
sort(vec.begin(),vec.end());
while(n--){
long long num;
scanf("%lld",&num);
if(num==1){
printf("2\n");
continue;
}
int index=lower_bound(vec.begin(),vec.end(),num)-vec.begin();
printf("%lld\n",vec[index]);
}
return 0;
}
相关文章推荐
- 51Nod-1010 只包含因子2 3 5的数【打表+排序+二分搜索】
- 51nod 1010 只包含因子2 3 5的数【打表+二分】
- 51nod 1010 只包含因子2 3 5的数 打表二分
- 51nod 1010 只包含因子2 3 5的数 (打表+二分)
- 51Nod 1010 只包含因子2 3 5的数(打表+二分)
- 51nod 1010 只包含因子2 3 5的数(预处理+二分)
- 51NOD 1010 只包含因子2 3 5的数(二分 + 预处理)
- 51nod 1010 只包含因子2 3 5的数 【容器 +二分 】
- 51nod 只包含因子2 3 5的数 dfs打表+二分
- 51Nod 1010 只包含因子2 3 5的数 | 预处理+二分
- 51nod 1010 只包含因子2 3 5的数 && poj - 1338 Ugly Numbers(打表)
- 1010 只包含因子2 3 5的数(打表+二分)
- 51nod 1010 只包含因子2 3 5的数 打表
- 【51nod】--1010 只包含因子2 3 5的数 (二分&&数论&&打表)
- 51nod--1010 只包含因子2 3 5的数
- 51nod 1010《只包含因子2 3 5的数》
- 1010 只包含因子2 3 5的数(预处理+二分)
- 51nod 1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数(打表+二分)
- 51nod 1010 只包含因子2 3 5的数