Cod sursa(job #1384806)

Utilizator AndreiMedarMedar Andrei AndreiMedar Data 11 martie 2015 14:11:51
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>
using namespace std;

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

int fc(int p)
{
int i=0;
int pas=1<<16;
while(pas!=0)
{
if(zero(i+pas)<p)
i+=pas;
pas/=2;
}
return i+1;
}

int main()
{
    int p;
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>p;
    if(p<2)
    g<<"1";
    else
    {
    g<<fc(p);
    }



    return 0;
}