Cod sursa(job #1509593)

Utilizator t3odor131Baltoi Teodor Ioan t3odor131 Data 24 octombrie 2015 08:57:57
Problema Factorial Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int x[10000], y[100000];
int main()
{
    int P, x, y;
    fin>>P;
    x=0;
    if(P==0) fout<<1;
    else{
    while(P>0)
    {
        x=x+5;
        y=x;
        P--;
        y=y/5;
        while(y%5==0)
        {
            y=y/5;
            P--;
        }
    }
    if(P<0) fout<<-1;
    else fout<<x;
    }
    return 0;
}