Cod sursa(job #188617)

Utilizator iuly2freemanVasiliev Iulian iuly2freeman Data 9 mai 2008 12:25:31
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include<fstream>
#include<iostream>

using namespace std;

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

long long int P,p,nr,ind;

int main(){

    fin >> P;

    while(p<P){
        nr+=5;
        ind=nr;
        while (ind%5==0){
            ind=ind/5;
            p++;
        }
    }

    if (p>P) nr=-1;
    if (P==0) nr=1;

    fout << nr;

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

}