Ehab and a Special Coloring Problem

F. Ehab and a Special Coloring Problem

You're given an integer n n n. For every integer i i i from 2 2 2 to n n n, assign a positive integer a i a_i ai such that the following conditions hold:

  • For any pair of integers ( i , j ) (i,j) (i,j), if i i i and j j j are coprime, a i ≠ a j a_i \neq a_j ai=aj.
  • The maximal value of all a i a_i ai should be minimized (that is, as small as possible).

A pair of integers is called coprime if their greatest common divisor is 1 1 1.

Input

The only line contains the integer n n n ( 2 ≤ n ≤ 1 0 5 2 \le n \le 10^5 2≤n≤105).

Output

Print n − 1 n-1 n−1 integers, a 2 a_2 a2, a 3 a_3 a3, ... \ldots ..., a n a_n an ( 1 ≤ a i ≤ n 1 \leq a_i \leq n 1≤ai≤n).

If there are multiple solutions, print any of them.

Example

Input

cpp 复制代码
4

Output

cpp 复制代码
1 2 1

Input

cpp 复制代码
3

Output

cpp 复制代码
2 1

Node

In the first example, notice that 3 3 3 and 4 4 4 are coprime, so a 3 ≠ a 4 a_3 \neq a_4 a3=a4. Also, notice that a = [ 1 , 2 , 3 ] a=[1,2,3] a=[1,2,3] satisfies the first condition, but it's not a correct answer because its maximal value is 3 3 3.

code

cpp 复制代码
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
 
using namespace std;


const int N = 2e5+10,INF=0x3f3f3f3f,mod=1e9+7;
 
typedef pair<int,int> PII;

int T=1;

void solve(){
	int n;
	cin>>n;
	vector<int> a(n+5,0);
	int k=2;
	for(int i=2;i<=n;i++){
		if(i%2==0) a[i]=1;
		else{
			if(a[i]==0){
				a[i]=k++;
				for(int j=2;j<n && i*j<=n;j++) a[i*j]=a[i];
			}else{
				continue;
			}
		}
	}
	for(int i=2;i<=n;i++) cout<<a[i]<<" ";
}

signed main(){
//	cin>>T; 
    while(T--){
        solve();
    }
    return 0;
}
相关推荐
岑梓铭17 小时前
《考研408数据结构》第四章(串和串的算法)复习笔记
数据结构·笔记·考研·算法
2401_8414956417 小时前
【数值分析】插值法实验
python·数学·算法·可视化·数值分析·数学原理·插值法
Tony_yitao17 小时前
符号运算(华为OD)
java·算法·华为od
feifeigo12318 小时前
MATLAB的无线传感器网络(WSN)算法仿真
网络·算法·matlab
胖咕噜的稞达鸭18 小时前
缝合怪deque如何综合list和vector实现及仿函数模板如何优化priority_queue实现
数据结构·c++·算法·链表·list
tt55555555555518 小时前
C++ 经典数组算法题解析与实现教程
开发语言·c++·算法
美团技术团队18 小时前
可验证过程奖励在提升大模型推理效率中的探索与实践
人工智能·算法
小邓儿◑.◑19 小时前
贪心算法 | 每周8题(二)
c++·算法·贪心算法
用户9019518242419 小时前
【征文计划】基于 CXR-M SDK 打造 “AR 眼镜 + 手机” 户外步徒协同导航系统
算法