HDU 5878 I Count Two Three(2016亚洲区青岛站网络赛)

题目链接:http://acm.split.hdu.edu.cn/contests/contest_showproblem.php?pid=1001&cid=723
//又是五个小时,一天没吃东西,快虚脱了

#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=1e9+2;
int n,m,k,p,q,t;
int a[200010],b[100002];
int st(int x)
{
    if(x==1)
        return 2;
    if(x==2)
        return 3;
    if(x==3)
        return 5;
    return 7;
}


void dfs(int y)
{
    if(y==5)
        return;
    ll x;
    for(x=st(y); x<=N; x*=st(y))
    {
        for(int i=m; i; i--)
            if(a[i]*x<=N)
                a[++m]=a[i]*x;
    }
    dfs(y+1);
}
int main()
{
    scanf("%d",&k);
    a[m=1]=1;
    dfs(1);
    sort(a+1,a+m+1);
    while(~scanf("%d",&n))
    {
        t=a[lower_bound(a+1,a+m+1,n)-a];
        printf("%d\n",t);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值