Cod sursa(job #2618093)
| Utilizator | Data | 23 mai 2020 17:15:01 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <iostream>
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n;
int nz(int n)
{
int x=0;
while(n>=5)
{
n/=5;
x+=n;
}
return x;
}
int cbin(int x, int y){
if(x>y)
return -1;
int m=(y-x)/2+x;
int z=nz(m);
if(z==n)
return m;
if(z>n)
return cbin(x, m-1);
return cbin(m+1, y);
}
int main()
{
f>>n;
if(n==0)
g<<1;
else
{
int x = cbin(0, n*5);
x-=x%5;
g<<x;
}
return 0;
}
