結果
問題 | No.3020 ユークリッドの互除法・改 |
ユーザー |
|
提出日時 | 2025-02-23 16:26:15 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 967 bytes |
コンパイル時間 | 17,610 ms |
コンパイル使用メモリ | 171,076 KB |
実行使用メモリ | 188,540 KB |
最終ジャッジ日時 | 2025-02-23 16:26:36 |
合計ジャッジ時間 | 20,756 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (125 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); static long[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var a = NArr(2); var x = Math.Abs(a[0][0] * a[1][1] - a[0][1] * a[1][0]); var gcd = GCD(GCD(a[0][0], a[0][1]), GCD(a[1][0], a[1][1])); if (x == 0) WriteLine($"{gcd} 0"); else WriteLine($"{gcd} {x / gcd}"); } static long GCD(long a, long b) { if (a < 0) a = -a; if (b < 0) b = -b; if (a == 0) return b; if (b == 0) return a; if (a < b) return GCD(b, a); if (a % b == 0) return b; return GCD(b, a % b); } }