Cod sursa(job #2073649)

Utilizator ioana.jianuIoana Jianu ioana.jianu Data 23 noiembrie 2017 15:03:22
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int v[801];

int fact(int x){
    int suma=0,p=5;
    while(x/p>0){
        suma+=x/p;
        p*=5;
    }
    return suma;
}

int main(){

    freopen("fact.in","r",stdin);
    freopen("fact.out","w",stdout);

    int putere,s,p;

    scanf("%d",&p);

    putere=1<<30;
    s=0;
    while(putere>0){
        if(fact(s+putere)<=p-1)
            s+=putere;
        putere/=2;
    }

    printf("%d",s+1);

    return 0;
}