Cod sursa(job #956459)
Utilizator | Data | 3 iunie 2013 10:51:34 | |
---|---|---|---|
Problema | NumMst | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
int N;
priority_queue<int,vector<int>,greater<int> > q;
int main(){
freopen("nummst.in","r",stdin);
freopen("nummst.out","w",stdout);
scanf(" %d",&N);
for( int i=2 ; i<=N ; i++ )
if( N%i==0 ){
for( int j=1 ; j<=i ; j++ )
q.push(N/i);
break;
}
while( (int)q.size()>2 ){
int a=q.top();
q.pop();
int b=q.top();
q.pop();
q.push(a+b);
}
while( !q.empty() ){
printf("%d ",q.top());
q.pop();
}
return 0;
}