結果
問題 | No.2953 Maximum Right Triangle |
ユーザー |
|
提出日時 | 2025-01-26 20:53:35 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 1,201 bytes |
コンパイル時間 | 13,668 ms |
コンパイル使用メモリ | 170,392 KB |
実行使用メモリ | 191,440 KB |
最終ジャッジ日時 | 2025-01-26 20:53:53 |
合計ジャッジ時間 | 15,128 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (160 ミリ秒)。 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 int[] NList => ReadLine().Split().Select(int.Parse).ToArray();public static void Main(){Solve();}static void Solve(){var t = NN;var ans = new long[t];for (var u = 0; u < t; ++u){var c = NList;ans[u] = Tri(c[0], c[1], c[2]);}WriteLine(string.Join("\n", ans));}static long Tri(long d, long x, long y){if (x == 0){return y * d;}if (y == 0){return x * d;}var gcd = GCD(x, y);var dx = x / gcd;var dy = y / gcd;var maxa = Math.Min(x / dy, (d - y) / dx);var mina = Math.Max((x - d) / dy, - y / dx);return (x * x + y * y) / gcd * Math.Max(Math.Abs(maxa), Math.Abs(mina));}static long GCD(long a, long b){if (a < b) return GCD(b, a);if (a % b == 0) return b;return GCD(b, a % b);}}