Codeforces Round #199 (Div. 2) A Xenia and Divisors

时间:2023-12-15 21:29:02

注意题目的数字最大是7 而能整除的只有 1,2,3,4,6,故构成的组合只能是1,2,4 或1,2,6或1,3,6,故分别统计1,2,3,4,6的个数,然后再分配

 #include <iostream>
#include <vector>
#include <algorithm>
#include <string> using namespace std; int main(){
int n;
cin >> n ;
vector<int> a1,a2,a3,a4,a6;
int tmp;
for(int i = ; i < n; i ++ ){
cin >>tmp;
if(tmp != && tmp != && tmp != && tmp != && tmp!=) { cout<<-<<endl; return ;}
switch(tmp){
case :
a1.push_back(tmp);
break;
case :
a2.push_back(tmp);
break;
case :
a3.push_back(tmp);
break;
case :
a4.push_back(tmp);
break;
case :
a6.push_back(tmp);
break;
}
}
int len1 = a1.size(),len2 = a2.size(),len3 = a3.size(),len4 = a4.size(),len6 = a6.size();
if( (len1=len1-len4)>= && (len2=len2 - len4 )>= &&
(len1= len1-len3)>= && (len6 = len6 - len3) >= &&
(len1== len2 && len2 == len6)){
for(int i = ; i < a4.size(); ++ i)
cout<<<<" "<<<<" "<<<<endl;
for(int i = ; i < a3.size(); ++ i)
cout<<<<" "<<<<" "<<<<endl;
for(int i = ; i < a6.size()-a3.size(); ++ i)
cout<<<<" "<<<<" "<<<<endl;
}
else{
cout<<-<<endl;
} return ;
}