結果
問題 | No.3020 ユークリッドの互除法・改 |
ユーザー |
![]() |
提出日時 | 2025-02-14 22:17:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 594 bytes |
コンパイル時間 | 3,287 ms |
コンパイル使用メモリ | 274,768 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-14 22:17:58 |
合計ジャッジ時間 | 4,224 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>int main() {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);long long A[2][2];for (int i = 0; i < 2; i++) {for (int j = 0; j < 2; j++) {std::cin >> A[i][j];}}if (A[0][0] == A[1][0] && A[1][0] == A[1][1] && A[1][1] == A[0][1] && A[0][1] == 0) {std::cout << "0 0\n";return 0;}long long D[2];D[0] = std::gcd(A[0][0], A[0][1]);for (int i = 0; i < 2; i++) {D[0] = std::gcd(A[1][i], D[0]);}D[1] = std::abs(A[0][0] * A[1][1] - A[0][1] * A[1][0]) / D[0];std::cout << D[0] << ' ' << D[1] << '\n';}