結果
| 問題 |
No.3020 ユークリッドの互除法・改
|
| コンテスト | |
| ユーザー |
ジュ・ビオレ・グレイス
|
| 提出日時 | 2025-02-10 20:13:15 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 519 bytes |
| コンパイル時間 | 1,003 ms |
| コンパイル使用メモリ | 88,304 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-10 20:13:38 |
| 合計ジャッジ時間 | 1,727 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 1 WA * 20 |
ソースコード
import std.algorithm, std.array, std.conv, std.math, std.range, std.stdio, std.typecons;
long gcd2(long a, long b) {
if (b == 0) return a.abs();
else return gcd2(b, a%b);
}
long gcd(long a, long[] b ...) {
if (b.empty) return a;
return gcd( gcd2(a, b[0]), b[1 .. $] );
}
void main() {
auto row1 = readln.split.to!(long[]);
auto row2 = readln.split.to!(long[]);
auto g = gcd(row1[0], row1[1], row2[0], row2[1]);
if (g == 0) writeln("0 0");
else writeln(g, ( row1[0]*row2[1] - row2[0]*row1[1] ).abs() / g );
}
ジュ・ビオレ・グレイス