Cod sursa(job #291034)

Utilizator mathboyDragos-Alin Rotaru mathboy Data 29 martie 2009 11:58:30
Problema Numere 2 Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#define max 1000000
#include<stdio.h>
long long n[max];
int main()

{long long a,d,aux,p,b,i,max1=0;
    freopen("numere2.in","r",stdin);
    freopen("numere2.out","w",stdout);
    for(i=1;i<=max;i++)
    n[i]=0;
 scanf("%lld",&p);
   aux=p;d=2;
   while(aux!=1)
   {while(aux%d==0) 
      {aux/=d;n[d]++;}
      d++;if(max1<d) max1=d;
}
for(i=1;i<=max1;i++)
 if(n[i]!=0)printf("%lld\n%lld ",i,n[i]);
 return 0;
}