Mai intai trebuie sa te autentifici.
Cod sursa(job #2772402)
Utilizator | Data | 1 septembrie 2021 01:30:34 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 1.2 kb |
#include <iostream>
#include <chrono>
#include <fstream>
using namespace std::chrono;
std::ifstream f1("fact.in");
std::ofstream f2("fact.out");
//int pof(int t) {
// if (t % 5 == 0) {
// return 1 + pof(t / 5);
// }
// return 1;
//}
int zeros(int n) {
int res = 0;
while (n = n / 5) {
res += n;
}
return res;
}
void factorial() {
int target;
// std::ifstream f1(stdin);
// std::ofstream f2(stdout);
// f2 << "input: ";
std::ifstream f1("../in.txt");
std::ofstream f2("../out.txt");
f1 >> target;
for (int i = 0; i <= 1e10; i += 5) {
int zr = zeros(i);
if (zr == target) {
f2 << i << std::endl;
return;
}
}
// int counter = 0;
// while (target > 0) {
// counter += 5;
// target -= pof(counter / 5);
// }
// f2 << counter << std::endl;
}
int main() {
auto start = high_resolution_clock::now();
factorial();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
std::cout << std::endl << "[time]:" << duration.count() << std::endl;
return 0;
}