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

Posted huangdf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #563 (Div. 2)C. Ehab and a Special Coloring Problem相关的知识,希望对你有一定的参考价值。

原文链接:传送门
思路:素数筛
代码:

 1 #include"iostream"
 2 #include"algorithm"
 3 #include"cstring"
 4 using namespace std;
 5 long long  a[2000006],n;
 6 int main(){
 7     cin>>n;
 8     long long  flag = 1;
 9     memset(a,0,sizeof(a));
10     for(int i=2;i<=n;i++){
11         if(a[i]==0){
12             a[i]=flag;
13             for(int j=i*2;j<=n;j+=i)
14              if(a[j]==0)
15               a[j]=flag;
16               flag++;
17         }
18         cout<<a[i];
19         if(i<n)
20         cout<<" ";
21     }
22     return 0;
23 }

 

 



以上是关于Codeforces Round #563 (Div. 2)C. Ehab and a Special Coloring Problem的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #563 (Div. 2)

Codeforces Round #563 (Div. 2)

Codeforces Round 563 (Div. 2) 题解

Codeforces Round #563 (Div. 2) DEhab and the Expected XOR Problem

Codeforces Round #563 (Div. 2)B;Ehab Is an Odd Person

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