Cod sursa(job #2699372)

Utilizator TheGodFather2131Alexandru Miclea TheGodFather2131 Data 24 ianuarie 2021 12:20:18
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.18 kb
//ALEXANDRU MICLEA

#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
#include <assert.h>
#include <iostream>

using namespace std;
using ll = long long;

#define fast_cin() 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

//VARIABLES

vector <int> m5;
const int maxn = 100000005;
int v[maxn];

//FUNCTIONS



//MAIN
int main() {

	#ifdef INFOARENA
		freopen("", "r", stdin);
		freopen("", "w", stdout);
	#endif

	fast_cin();

	for (int i = 5; i < maxn; i *= 5) {
		for (int j = i; j < maxn; j += i) {
			v[j]++;
		}
	}

	for (int i = 1; i < maxn; i++) {
		v[i] += v[i - 1];
	}

	int p; cin >> p;
	
	int ans = -1;

	int st = 1, dr = maxn;
	while (st <= dr) {
		int mid = (st + dr) / 2;

		if (v[mid] == p && (mid % 5) == 0) ans = mid;
		if (v[mid] < p) st = mid + 1;
		else dr = mid - 1;
	}
	cout << ans << '\n';

	return 0;
}