Cod sursa(job #1209212)

Utilizator cristibogdanPatrascu Cristian cristibogdan Data 17 iulie 2014 12:35:02
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <fstream>

using namespace std;
ifstream f ("fact.in");
ofstream g("fact.out");
int t,p,st,dr,mij,a;



int zero(long long n){
        long long p=5;
        int r=0;
        int g;
            while(g=(n/p)){
                r+=g;
                p=p*5;
            }
            return r;}

int main()
{
    f>>p;
    if(p==0)
        g<<1;
    else{
    st=1;
    dr=p*5;
        while(st<=dr){
            mij=st+(dr-st)/2;
            a=zero(mij);
            if(a<p)
                st=mij+1;
            else
                dr=mij-1;
        }
        if(zero(st)==p)
            g<<st;
        else
            g<<-1;}


    return 0;
}