結果
問題 | No.3020 ユークリッドの互除法・改 |
ユーザー |
|
提出日時 | 2025-02-14 21:37:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 2,128 ms |
コンパイル使用メモリ | 197,600 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-14 21:37:08 |
合計ジャッジ時間 | 3,106 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> istream& operator >> (istream& is, vector<T>& vec) { for(T& x : vec) is >> x; return is; } template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); vector A(2, vector<ll>(2)); cin >> A; ll g = gcd(A[0][0], A[0][1]); g = gcd(g, gcd(A[1][0], A[1][1])); ll d = abs(A[0][0] * A[1][1] - A[1][0] * A[0][1]); if(g == 0){ cout << 0 << " " << 0 << '\n'; return 0; } cout << g << " " << d / g << '\n'; }