Cod sursa(job #1508094)

Utilizator RaduMirceaAndreiRadu Mircea Andrei RaduMirceaAndrei Data 22 octombrie 2015 12:02:50
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
# include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int st,dr,mij,p,p5,nr0;
int main () {
    fin>>p;
    st=1;
    dr=p*5;
    while(st<dr){
            fout<<mij<<" ";
        mij=(dr-st)/2;
        p5=5;
        nr0=0;
        while((mij/p5)>0){
            nr0=mij/p5+nr0;
            p5=p5*5;
        }
        if(nr0<p)
            st=mij+1;
        else
            dr=mij-1;
    }
    fout<<st;
    return 0;
}