/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 496.0 KiB
#2 Accepted 2ms 328.0 KiB
#3 Accepted 2ms 344.0 KiB
#4 Accepted 2ms 328.0 KiB
#5 Accepted 2ms 332.0 KiB
#6 Accepted 3ms 564.0 KiB
#7 Accepted 3ms 568.0 KiB
#8 Accepted 3ms 488.0 KiB
#9 Accepted 3ms 488.0 KiB
#10 Accepted 4ms 512.0 KiB
#11 Accepted 3ms 364.0 KiB
#12 Accepted 3ms 332.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long

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:20
Judged At
2024-11-11 02:44:11
Judged By
Score
100
Total Time
4ms
Peak Memory
568.0 KiB