Cod sursa(job #918707)

Utilizator pauldinudinu paul pauldinu Data 19 martie 2013 07:58:42
Problema Factorial Scor 85
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");
int zero(int x)
{
    int r=0;
    while(x>=5)
    {
        r=r+x/5;
        x=x/5;
    }
    return r;
}
int cautare(int x)
{
    int i=0,pas=1<<30;
    while(pas!=0)
    {
    if(zero(i+pas)<=x)
            i+=pas;
        pas/=2;
    }
return i+1;
}
int main()
{
    int p;
    f>>p;
    g<<cautare(p)-5;
    return 0;
}