题目大意:给你一个n,分解为k个数,这k个数可以相同,相乘要等于n
根据唯一分解定理,将n分解为质因数的形式
#include<iostream>
#include<vector>
using namespace std;
vector<int> vec;
void fun(int n){
for(int i=2;i*i<=n;i++){
while(n%i==0){
vec.push_back(i);
n/=i;
}
}
if(n!=1) vec.push_back(n);
}
int main(){
int n,k;
while(cin>>n>>k){
vec.clear();
fun(n);
if(vec.size()<k) cout<<-1<<endl;
else{
for(int i=0;i<k-1;i++){
cout<<vec[i]<<' ';
}
int ans=1;
for(int i=k-1;i<vec.size();i++){
ans*=vec[i];
}
if(ans>1){
cout<<ans<<endl;
}
}
}
}