Cod sursa(job #1003927)
Utilizator | Data | 1 octombrie 2013 19:39:57 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n;
int term(int k)
{
int r=5,rez=0;
while (k/r)
{
rez+=k/r;
r*=5;
}
return rez;
}
int main()
{
int m,st=1,dr=100000000;
f>>n;
while (st<=dr)
{
m=(st+dr)/2;
if (term(m)>=n) dr=m-1;
else st=m+1;
}
g<<dr+1<<'\n';
return 0;
}