Cod sursa(job #1688101)

Utilizator DaniellDa Vinci Daniell Data 13 aprilie 2016 11:36:14
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>

using namespace std;
int n,p,i,k=0,h,j,w,c;
ifstream fin("fact.in");
ofstream fout("fact.out");

int main()
{fin>>p;
if(p==0)fout<<"1";
else{

while(k!=p)
{
    h=h+5;k++;
    if((h/5)%5==0 && h/5>0 ){
            w=h/5;
    while(w%5==0){
        w=w/5;k++;
    }

    }
    if(k>p){fout<<"-1";break;}
}
if(k==p)fout<<h;
}
    return 0;
}