Cod sursa(job #1599882)

Utilizator DaniellDa Vinci Daniell Data 14 februarie 2016 14:43:34
Problema Factorial Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 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){
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";}
else fout<<h;
}
else fout<<"1";
    return 0;
}