-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (50 loc) · 1.25 KB
/
main.cpp
File metadata and controls
59 lines (50 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define endl '\n'
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define prec(x) fixed << setprecision(x)
#define testcase cout << "Case " << cs++ << ":"
//stol(s);sqrtl() to_string(x);
template <typename T>
using minHeap = priority_queue<T, vector<T>, greater<T>>;
const ld PI = acos((ld) - 1);
const int MOD = 1e9 + 7;
const ll INF = 2e18 + 1;
const ld EPS = 1e-9;
const int MX = 2e6;
int cs = 1;
ll a, b, c, pos;
ll check(ll x){
ll i = a * b, j = b * c, k = a * c;
ll ans = (x/i) + (x/j) + (x/k);
ans -= ((x / lcm(i, j)) + (x / lcm(j, k)) + (x / lcm(i, k)) + );
return ans;
}
void solve(){
cin >> a >> b >> c >> pos;
ll lo = 0, hi = 1e18, ans = -1;
while(lo <= hi){
ll mid = lo + (hi - lo) / 2;
if(check(mid) >= pos){
ans = mid;
hi = mid - 1;
} else lo = mid + 1;
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin >> t;
//cin.ignore();
while (t--) {
solve();
}
return 0;
}