题解:P11124 [ROIR 2024 Day 2] 数组划分
传送门
在这道题目中,
Code
#include<bits/stdc++.h>
using namespace std;
int n;
int f(int k){//
int cnt=0;
for(int i=2;i<=k/i;i++){//进行质因数分解
while(k%i==0){
cnt++;
k/=i;
}
}
if(k>1){
cnt++;
}
return cnt;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
int a;
cin>>a;
if(f(a)&1){//是奇数放到一组
cout<<1<<' ';
}else{
cout<<2<<' ';//是偶数放到一组
}
}
return 0;
}