Cod sursa(job #799928)

Utilizator rapidistulfiorosTudor Daniel Marin rapidistulfioros Data 20 octombrie 2012 13:40:57
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<stdio.h>

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


int caut(int x){
    int i=0,pas;
    pas=1<<29;
    while(pas!=0)
    {
        if(zero(i+pas)<x)
            i += pas;
        pas /= 2;
    }
    return i+1;
}

int main(){
    freopen("fact.in","r",stdin);
    freopen("fact.out","w",stdout);
    int p, r;
    scanf("%d",&p);
    r = caut(p);
    printf("%d\n",r);
    return 0;
}