Cod sursa(job #828875)

Utilizator RaresGabrielMircea Rares-Gabriel RaresGabriel Data 4 decembrie 2012 16:26:44
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include<iostream>
#include<cmath>
#include<fstream>

using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");

int main () {
     int p,k=0,n=0,y=0;
     fin>>p;
     if(p==0)fout<<"-1";
     while(n!=p){y=y+5;
                         k=y;
                        while(k%5==0){k=k/5;
                                                  n++;}
     }

    if(n!=p||p<0)fout<<"-1";
       else fout<<y;

    fin.close();
    fout.close();

    return 0;
}