You're given an integer nn. For every integer ii from 22 to nn, assign a positive integer aiai such that the following conditions hold:

  • For any pair of integers (i,j)(i,j), if ii and jj are coprime, ai≠ajai≠aj.
  • The maximal value of all aiai should be minimized (that is, as small as possible).

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

Input

The only line contains the integer nn (2≤n≤1052≤n≤105).

Output

Print n−1n−1 integers, a2a2, a3a3, ……, anan (1≤ai≤n1≤ai≤n).

If there are multiple solutions, print any of them.

Examples
input

Copy
4
output

Copy
1 2 1 
input

Copy
3
output

Copy
2 1
Note

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


素数筛选:

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const int maxn = 1e5 + ; int main()
{
int n;
cin >> n;
int cnt=;
vector<int> a(maxn);
vector<bool> b(maxn);
for (int i = ; i <= n; i++)
{
if (!b[i])
{
a[i] = ++cnt;
for (int j = i + i; j <= n; j += i)
b[j] = , a[j] = a[i];
}
} for (int i = ; i <= n; i++)
cout << a[i] << " ";
return ;
}

Ehab and a Special Coloring Problem的更多相关文章

  1. Codeforces Round #563 (Div. 2) C. Ehab and a Special Coloring Problem

    链接:https://codeforces.com/contest/1174/problem/C 题意: You're given an integer nn. For every integer i ...

  2. Codeforces 1174C Ehab and a Special Coloring Problem

    题目链接:http://codeforces.com/problemset/problem/1174/C 题意:给你一个n,要你填充 下标由2 ~ n 的数组ai,要求下标互质的俩个数不能相等,并且数 ...

  3. CF1174C Ehab and a Special Coloring Problem(数论)

    做法 与\(x\)互质的数填不同的数,把有向关系表示出来,发现边数是不能承受的 反过来想,成倍数关系填相同的数,把这些数想象成一条链,而这条链开始的数一定是质数,\(\sum\limits_{prim ...

  4. Codeforces 1088E Ehab and a component choosing problem

    Ehab and a component choosing problem 如果有多个连接件那么这几个连接件一定是一样大的, 所以我们先找到值最大的连通块这个肯定是分数的答案. dp[ i ]表示对于 ...

  5. Codeforces Round #525 (Div. 2)E. Ehab and a component choosing problem

    E. Ehab and a component choosing problem 题目链接:https://codeforces.com/contest/1088/problem/E 题意: 给出一个 ...

  6. Codeforces Round #525 (Div. 2)D. Ehab and another another xor problem

    D. Ehab and another another xor problem 题目链接:https://codeforces.com/contest/1088/problem/D Descripti ...

  7. [E. Ehab's REAL Number Theory Problem](https://codeforces.com/contest/1325/problem/E) 数论+图论 求最小环

    E. Ehab's REAL Number Theory Problem 数论+图论 求最小环 题目大意: 给你一个n大小的数列,数列里的每一个元素满足以下要求: 数据范围是:\(1<=a_i& ...

  8. 题解-Ehab's REAL Number Theory Problem

    Ehab's REAL Number Theory Problem 前置知识 质数 分解质因数 无向无权图最小环<讲> Ehab's REAL Number Theory Problem/ ...

  9. codeforces#1157D. Ehab and the Expected XOR Problem(构造)

    题目链接: http://codeforces.com/contest/1174/problem/D 题意: 构造一个序列,满足以下条件 他的所有子段的异或值不等于$x$ $1 \le a_i< ...

随机推荐

  1. ASP.NET常用内置对象(一)Request

    用来获取客户端在请求一个页面或传送一个Form是提供的所有信息.它包括用户的HTTP变量.能够识别的浏览器信息.存储客户端的Cookie信息和请求地址等. Request对象是System.Web.H ...

  2. 题解 P5712 【【深基3.例4】Apples】

    题目传送门 思路 仔细读题后,我们可以发现,输出可以分成\(2\)种情况,apple加s与apple不加s,所以我们可以使用if/else来实现. 接着,我们读入n. int n; cin>&g ...

  3. 0级搭建类004-中标麒麟 Linux 安装 (V7.0) 公开

    项目文档引子系列是根据项目原型,制作的测试实验文档,目的是为了提升项目过程中的实际动手能力,打造精品文档AskScuti. 项目文档引子系列目前不对外发布,仅作为博客记录.如学员在实际工作过程中需提前 ...

  4. jQuery---音乐导航

    音乐导航 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...

  5. jQuery---手风琴案例

    手风琴案例 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF ...

  6. 850. Dijkstra求最短路 II(堆优化模板)

    给定一个n个点m条边的有向图,图中可能存在重边和自环,所有边权均为非负值. 请你求出1号点到n号点的最短距离,如果无法从1号点走到n号点,则输出-1. 输入格式 第一行包含整数n和m. 接下来m行每行 ...

  7. npm命令笔记-----转自网络,仅供自己查看使用

    npm是一个node包管理和分发工具,已经成为了非官方的发布node模块(包)的标准.有了npm,可以很快的找到特定服务要使用的包,进行下载.安装以及管理已经安装 的包. npm常用指令 1.npm ...

  8. Phalanx HDU - 2859 dp

    #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> us ...

  9. nginx配置从远程获取静态资源

    前置条件:现有两台内网互通机器192.168.0.100.192.168.0.101,其中192.168.0.100可以通过外网网络.业务需求:需要通过外网访问处于192.168.0.101机器上的静 ...

  10. mysql 基础sql语法总结 (二)DML

    二.DML(增.删.改) 1)插入数据 第一种写法:INSERT INTO 表名 (列名1,列名2,,......)VALUES(列值1,列值2,......) 第二种写法:INSERT INTO 表 ...