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;
}
相关推荐
啊阿狸不会拉杆33 分钟前
人工智能数学基础(二):初等数学
人工智能·python·算法
元亓亓亓42 分钟前
LeetCode热题100--560.和为K的子数组(前缀和)--中等
算法·leetcode·职场和发展
Phoebe鑫1 小时前
数据结构每日一题day12(链表)★★★★★
数据结构·算法·链表
Vacant Seat1 小时前
贪心算法-跳跃游戏II
算法·游戏·贪心算法
夜松云2 小时前
从对数变换到深度框架:逻辑回归与交叉熵的数学原理及PyTorch实战
pytorch·算法·逻辑回归·梯度下降·交叉熵·对数变换·sigmoid函数
八股文领域大手子2 小时前
深入浅出限流算法(三):追求极致精确的滑动日志
开发语言·数据结构·算法·leetcode·mybatis·哈希算法
啊阿狸不会拉杆2 小时前
人工智能数学基础(一):人工智能与数学
人工智能·python·算法
一捌年2 小时前
java排序算法-计数排序
数据结构·算法·排序算法
freexyn3 小时前
Matlab自学笔记五十二:变量名称:检查变量名称是否存在或是否与关键字冲突
人工智能·笔记·算法·matlab
渭雨轻尘_学习计算机ing3 小时前
二叉树构建算法全解析
算法·程序员