Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll lcm(ll a, ll b) {
ll res = a * b;
return (res / __gcd(a, b));
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
ll a, b, c, x;
cin >> a >> b >> c >> x;
ll L = lcm(a, b);
L = lcm(L, c);
ll ans = (L * (--x / L));
cout << (!ans ? -1 : ans) << '\n';
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1025 GCM
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-03 22:06:09
- Judged At
- 2024-11-11 02:44:11
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 580.0 KiB