Cod sursa(job #3232650)
| Utilizator | Data | 31 mai 2024 19:09:57 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int v[100001],n;
bool ok(int val,int target)
{
long long p5=5,cnt=0;
while(p5<=val)
{
cnt+=val/p5;
p5*=5;
}
return (cnt>=target);
}
int f(int val)
{
long long st=1,dr=1e8*5,mid,rasp;
while(st<=dr)
{
mid=(st+dr)/2;
if(ok(mid,val))
{
rasp=mid;
dr=mid-1;
}
else st=mid+1;
}
return rasp;
}
int main()
{
int p;
fin>>p;
fout<<f(p);
return 0;
}
