Cod sursa(job #2103104)
| Utilizator | Data | 9 ianuarie 2018 19:50:58 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
#include <iostream>
#include <math.h>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int F(long long n)
{
int result=0;
long long exp=5;
while(n>=exp)
{
result+=n/exp;
exp*=5;
}
return result;
}
int main()
{
int N;
f>>N;
if(N==0) g<<1;
else
{
long long m,a=0,b=9223372036854775807;
while(a<b)
{
m=((a-b)>>1)+b;
if(F(m)<N) a=m+1;
else b=m-1;
}
g<<a;
}
return 0;
}
