# C. Beautiful Set----枚举

xiaoxiao2021-02-28  10

C. Beautiful Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

We'll call a set of positive integers a beautiful if the following condition fulfills: for any prime p, if , then . In other words, if one number from the set is divisible by prime p, then at least half of numbers from the set is divisible by p.

Your task is to find any beautiful set, where the number of elements is equal to k and each element doesn't exceed 2k2.

Input

The first line contains integer k (10 ≤ k ≤ 5000) that shows how many numbers the required beautiful set should have.

Output

In the first line print k space-separated integers that are a beautiful set. If there are multiple such sets, you are allowed to print any of them.

Examples input 10 output 16 18 24 27 36 48 54 72 108 144

http://vawait.com/2013/11/codeforces-364c/

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long lint; int a={0,2,3,5,7,11,13,17}; int n,m,ans,s,ma; void init(){ cin>>n; ma=n*n*2; } void dfs(int t,int k){ if(t>m){ ans[s++]=k; return; } dfs(t+1,k); while(k*a[t]<=ma){ k*=a[t]; dfs(t+1,k); } } void work(){ for(int i=2;i<=6;i++){ m=i; s=0; dfs(1,1); if(s<2*n) continue; sort(ans,ans+s); for(int j=1;j<=n-1;j++) printf("%d ",ans[s-j]); printf("%d\n",ans[s-n]); break; } } int main(){ init(); work(); return 0; }