Cod sursa(job #2197001)

Utilizator Vlad_ConstantinVlad Constantin Vlad_Constantin Data 20 aprilie 2018 21:08:08
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <iostream>
#include <cstdio>
using namespace std;

int numarzero(int n)
{
    int nr=0;
    while(n!=0)
    {
        nr=nr+n/5;
        n=n/5;
    }
    return nr;
}

int main()
{
    freopen("fact.in","r",stdin);
    freopen("fact.out","w",stdout);
    int P; scanf("%d", &P);
    int m,u,p;
    p=1;
    u=5*P+50;
    while (p<=u)
    {
        m = (p+u)/2;
        if (numarzero(m)>=P)
            u = m-1;
        else
            p = m+1;
    }

    cout<<p;
    return 0;
}