結果
問題 | No.3020 ユークリッドの互除法・改 |
ユーザー |
![]() |
提出日時 | 2025-02-10 20:12:21 |
言語 | D (dmd 2.109.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 519 bytes |
コンパイル時間 | 2,555 ms |
コンパイル使用メモリ | 90,736 KB |
実行使用メモリ | 16,072 KB |
最終ジャッジ日時 | 2025-02-10 20:13:37 |
合計ジャッジ時間 | 76,043 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 3 |
other | AC * 1 TLE * 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 );}