Cod sursa(job #2211525)
Utilizator | Data | 10 iunie 2018 19:39:46 | |
---|---|---|---|
Problema | Factorial | Scor | 85 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int n;
int zerouri(int n) {
int p=5,s=0;
while(n/p!=0) {
s+=n/p;
p*=5;
}
return s;
}
int main()
{
in >> n;
int x = -1;
for (int b = 5*n; b >= 1; b /= 2) {
while (zerouri(x+b)<n) x += b;
}
int k = x+1;
out << k;
return 0;
}