您的位置:首页 > 理论基础 > 计算机网络

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

2016-09-17 18:16 411 查看
题目链接: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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息