#include <iostream> #include <algorithm> using namespace std; #define MAXN 1e18 + 998 typedef long long ll; ll a[100010]; int main() { ll flag = 0; for(ll i = 1; i < MAXN; i *= 2) for(ll j = 1; i * j < MAXN; j *= 3) for(ll k = 1;i * j * k < MAXN; k *= 5) a[flag ++] = i * j * k; sort(a,a + flag); a[0] = -1; ll n, tmp, pos; cin>>n; while(n--) { cin>>tmp; pos = lower_bound(a,a + flag,tmp) - a;//容器开始地址, 容器结束地址, 搜索值 - 容器开始地址 = 容器中的相对位置 /*if(a[pos] == tmp) cout<<a[pos + 1]<<endl; else*/ cout<<a[pos]<<endl; } return 0; }
1010 只包含因子2 3 5的数 lower_boud
猜你喜欢
转载自blog.csdn.net/zeolim/article/details/80236359
今日推荐
周排行