Cod sursa(job #1687943)

Utilizator DaniellDa Vinci Daniell Data 13 aprilie 2016 10:04:16
Problema Factorial Scor 35
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");

void rez()
{w=h/5;
while(w%5==0)
    w=w/5,k++;

}

int main()
{fin>>p;

if(p==0)fout<<"1";
else{h=5;k++;
while(k!=p)
{
    h+=5;k++;
    if((h/5)%5==0)rez();


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

    return 0;
}