Cod sursa(job #2313171)
| Utilizator | Data | 6 ianuarie 2019 11:30:14 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include "pch.h"
#include <iostream>
#include <fstream>
ifstream f("fact.in");
ofstream g("fact.out");
int n;
long long r, pas;
int zero(int x) {
int ans = 0;
while (x >= 5) {
ans += x / 5;
x = x / 5;
}
return ans;
}
using namespace std;
int main()
{
f >> n;
pas = 1 << 30;
r = 0;
while (pas) {
if (zero(r + pas) < n) r += pas;
pas /= 2;
}
if (zero(r + 1) == n) {
g << r + 1 << '\n';
}
else {
g << -1;
}
return 0;
}
