标签:nbsp spec target def color special 思路 stream targe
原文链接:传送门
思路:素数筛
代码:
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
标签:nbsp spec target def color special 思路 stream targe
原文地址:https://www.cnblogs.com/huangdf/p/12222897.html