Cod sursa(job #2377858)

Utilizator bianca_maria06Bianca Ciobanu bianca_maria06 Data 11 martie 2019 11:45:54
Problema Factorial Scor 15
Compilator c-64 Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <stdio.h>
#include <stdlib.h>
const int L=28;
int nrzero(int n){
    int nr=0;
    while(n>=5){
      nr+=n/5;
      n/=5;
    }
    return nr;
}

int cautb(int p){
    int r=0,pas=1<<L;
    while(pas=0){
      if(nrzero(r+pas)<p){
        r+=pas;
      }
      pas/=2;
    }
    r++;
    if(nrzero(r)!=p){
      r=-1;
    }
    return r;
}
int main(){
    FILE*fin=fopen("fact.in", "r");
    FILE*fout=fopen("fact.out", "w");
    int p, rez;
    fscanf(fin,"%d",&p);
    rez = cautb(p);
    fprintf(fout,"%d",rez);
    fclose(fin);
    fclose(fout);
    return 0;
}