Cod sursa(job #2378202)
Utilizator | Data | 11 martie 2019 20:48:45 | |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream>
using namespace std;
ifstream in ("fact.in");
ofstream out ("fact.out");
int main (void)
{
int a,l=0,r=100000000,best=1;
in>>a;
while (l<=r)
{
int mid=(l+r)/2,sol=0;
for (int d=5;d<=mid;d*=5)
sol+=mid/d;
if (sol>=a)
{
best=mid;
r=mid-1;
}
else
l=mid+1;
}
out<<best;
return 0;
}