Cod sursa(job #2278217)

Utilizator maria_neagoieMaria Neagoie maria_neagoie Data 7 noiembrie 2018 14:45:53
Problema Factorial Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <cstdio>
using namespace std;
const int L=28;
int nrzero(int n)
{
    int cnt=0;
    while(n>=5)
    {
        cnt=cnt+n/5;
        n=n/5;
    }
    return cnt;
}
int main()
{
    freopen("fact.in","r",stdin);
    freopen("fact.out","w",stdout);
    int n,pas=1<<L,r=0;
    scanf("%d",&n);
    while(pas)
    {
        if(nrzero(r+pas)<n)
            r=r+pas;
        pas=pas/2;
    }
    r++;
    if(nrzero(r)==n)
        printf("%d",r);
    else
        printf("-1");
    return 0;
}