Cod sursa(job #547121)

Utilizator fulgerulnegruFMI Ekart Dragos-Ioan fulgerulnegru Data 5 martie 2011 21:37:19
Problema Factorial Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<fstream>
using namespace std;
ifstream in ("fact.in");
ofstream out ("fact.out");
int main (){
    int n=0,n1,i=0,p,t,j;
    in>>p;
    //while(n1/t>0){
    //    i+=n1/t;
    //    t=t+5;
    //}
    while(i<p){
        n+=5;
        n1=n;
        while(n1%5==0){
            i++;
            n1=n1/5;

    }
    }
    if(n==0)
    n++;
    if(p!=i)
    out<<-1;
    else
out<<n;
return 0;
}