Cod sursa(job #2078570)

Utilizator Cioarec_GeorgeCioarec George Cioarec_George Data 29 noiembrie 2017 18:59:35
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int z(int n)
{
    int s=0;
    while(n>=5)
        s+=(n/=5);
    return s;
}

int main()
{
    int r=0, pas=1<<28, p;
    f>>p;
    while(pas!=0)
    {
        if(z(r+pas)<p)
            r+=pas;
        pas/=2;
    }
    r++;
    if(z(r)!=p)
        r=-1;
    g<<r;
    return 0;
}