F. Kate and imperfection

194 篇文章 1 订阅
44 篇文章 0 订阅

链接:https://codeforc.es/contest/1333/problem/F

Kate has a set SS of nn integers {1,…,n}{1,…,n}.

She thinks that imperfection of a subset M⊆SM⊆S is equal to the maximum of gcd(a,b)gcd(a,b) over all pairs (a,b)(a,b) such that both aa and bb are in MM and a≠ba≠b.

Kate is a very neat girl and for each k∈{2,…,n}k∈{2,…,n} she wants to find a subset that has the smallest imperfection among all subsets in SS of size kk. There can be more than one subset with the smallest imperfection and the same size, but you don't need to worry about it. Kate wants to find all the subsets herself, but she needs your help to find the smallest possible imperfection for each size kk, will name it IkIk.

Please, help Kate to find I2I2, I3I3, ..., InIn.

Input

The first and only line in the input consists of only one integer nn (2≤n≤5⋅1052≤n≤5⋅105)  — the size of the given set SS.

Output

Output contains only one line that includes n−1n−1 integers: I2I2, I3I3, ..., InIn.

Examples

input

Copy

2

output

Copy

1 

input

Copy

3

output

Copy

1 1 

Note

First sample: answer is 1, because gcd(1,2)=1gcd(1,2)=1.

Second sample: there are subsets of SS with sizes 2,32,3 with imperfection equal to 1. For example, {2,3}{2,3} and {1,2,3}{1,2,3}.

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,t,l,k,s,sum;
long long a[500001],b[200001];
map<long long,long long>m;
int main()
{
    cin>>n;
	for(int i=1;i<=n;i++)
    a[i]=1;
    for(int i=2;i<=n;i++)
    {
    	if(a[i]==1)
    	{
	    	for(int j=i*2;j<=n;j+=i)
	    	{
	    		if(a[j]==1) 
	    		a[j]=j/i;
	    	}
    	}
    	
    }
    sort(a+1,a+1+n);
    for(int i=2;i<=n;i++)
    {
    	cout<<a[i]<<' ';
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值