Cod sursa(job #2078571)

Utilizator syndicat3albu alex syndicat3 Data 29 noiembrie 2017 19:00:08
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <iostream>

using namespace std;


int zero(int n){
int nr0=0;
while(n>=5){
nr0+=(n/=5);
}
return nr0;
}

int main()
{
    ifstream in("fact.in");
    ofstream out("fact.out");
    int p,r,pas;
    in>>p;
    r=0;
    pas=1<<28;
    while (pas!=0)
    {
        if (zero(r+pas)<p)
        {
            r+=pas;
        }
        pas/=2;
    }
    r++;
    if (zero(r)!=p) r=-1;
    out<<r;
    in.close();
    out.close();
    return 0;
}

    return 0;
}