結果
問題 | No.3020 ユークリッドの互除法・改 |
ユーザー |
![]() |
提出日時 | 2025-02-15 17:33:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,144 bytes |
コンパイル時間 | 530 ms |
コンパイル使用メモリ | 40,832 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-15 17:33:44 |
合計ジャッジ時間 | 1,864 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:49:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | scanf("%lld%lld%lld%lld", &a, &b, &c, &d); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-** 3020.cc: No.3020 繝ヲ繝シ繧ッ繝ェ繝・ラ縺ョ莠帝勁豕輔・謾ケ - yukicoder*/#include<cstdio>#include<algorithm>using namespace std;/* constant *//* typedef */using ll = long long;/* global variables *//* subroutines */void gcdrows(ll &a, ll &b, ll &c, ll &d) {if (a < 0) a = -a, b = -b;if (c < 0) c = -c, d = -d;while (c > 0) {ll x = a / c;a -= c * x, b -= d * x;swap(a, c), swap(b, d);}}void gcdcols(ll &a, ll &b, ll &c, ll &d) {if (a < 0) a = -a, c = -c;if (b < 0) b = -b, d = -d;while (b > 0) {ll x = a / b;a -= b * x, c -= d * x;swap(a, b), swap(c, d);}}void printmat(ll &a, ll &b, ll &c, ll &d) {printf("%lld %lld %lld %lld\n", a, b, c, d);}/* main */int main() {ll a, b, c, d;scanf("%lld%lld%lld%lld", &a, &b, &c, &d);//printmat(a, b, c, d);gcdrows(a, b, c, d);//printmat(a, b, c, d);gcdcols(a, b, c, d);//printmat(a, b, c, d);a += c, b += d;gcdcols(a, b, c, d);gcdrows(a, b, c, d);//printmat(a, b, c, d);printf("%lld %lld\n", abs(a), abs(d));return 0;}