Cod sursa(job #1539606)
Utilizator | Constantinescu Mirela miriconstantinescu | Data | 1 decembrie 2015 01:37:11 |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <fstream>
#include<algorithm>
using namespace std;
int zerouri (int n)
{
int rez=0;
while(n>=5)
{
rez+=n/5;
n=n/5;
}
return rez;
}
int caut (int p)
{
int i=0,pas=1<<30;
while(pas!=0)
{
if(zerouri(i+pas)<p)
i+=pas;
pas/=2;
}
return 1+i;
}
int main()
{
int p;
ifstream f("fact.in");
ofstream g("fact.out");
if(p==0)
g<<"1";
else
f>>p;
g<<caut(p);
return 0;
}