Cod sursa(job #1900953)
| Utilizator | Data | 3 martie 2017 17:52:09 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <fstream>
#include <cstdio>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main()
{
int N,P,x=0,y=10000000,i,p=5,s=0;
in>>P;
while(x<=y - 2)
{
i=(x+y)/2;
s = 0;
p = 5;
while(p<=i){
s=s+i/p;
p=p*5;
}
if(s<P)x=i;
else y=i;
}
out<<i;
return 0;
}
