Cod sursa(job #2058077)

Utilizator mdcoroiuCoroiu Mircea-Dumitru mdcoroiu Data 5 noiembrie 2017 05:56:36
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include<fstream>

using namespace std;

int main(){
   long long int fact, p, c0, n, k;
   ifstream f("fact.in");
   ofstream g("fact.out");
   f>>p;
   if(p==0) n=1;
   else{
    n=5;c0=1;
    while(c0<p){
        n+=5;
        k=n;
        while(k%10==0) {c0++; k=k/10;}
        while(k%5==0) {c0++; k=k/5;}
    }
    if(c0!=p) n=-1;
   }
   g<<n;
   f.close(); g.close();
   return 0;
}