Pagini recente » Cod sursa (job #2985256) | Borderou de evaluare (job #275906) | Cod sursa (job #2652410) | Cod sursa (job #2680674) | Cod sursa (job #585687)
Cod sursa(job #585687)
#include<stdio.h>
FILE*f=fopen("nummst.in","r");
FILE*g=fopen("nummst.out","w");
int n,nn,k,F[50000],P[50000],i;
inline void prelucrare () {
int i;
for ( i = 2 ; i * i <= n && n > 1 ; ++i ){
if ( !(n % i) ){
++k;
F[k] = i;
while ( !(n % i) ){
++P[k];
n /= i;
}
}
}
if ( n > 1 ){
++k;
F[k] = n;
P[k] = 1;
}
}
int main () {
fscanf(f,"%d",&n); nn = n;
if ( !(n & 1) ){
fprintf(g,"%d %d\n",n>>1,n>>1);
}
else{
prelucrare();
if ( k > 1 ){
for ( i = 1 ; i <= F[1] ; ++i ){
fprintf(g,"%d ",nn / F[1]);
}
}
else{
if ( nn & 1 ){
for ( i = 1 ; i <= ( n >> 1 ) - 1 ; ++i ){
fprintf(g,"2 ");
}
fprintf(g,"3 ");
}
}
}
fclose(f);
fclose(g);
return 0;
}