/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 480.0 KiB
#4 Accepted 2ms 324.0 KiB
#5 Accepted 2ms 532.0 KiB
#6 Accepted 2ms 484.0 KiB
#7 Accepted 2ms 532.0 KiB
#8 Accepted 2ms 580.0 KiB
#9 Accepted 2ms 320.0 KiB
#10 Accepted 2ms 320.0 KiB
#11 Accepted 2ms 332.0 KiB
#12 Accepted 2ms 484.0 KiB

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