結果
| 問題 |
No.2953 Maximum Right Triangle
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2024-11-08 21:29:49 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 991 bytes |
| コンパイル時間 | 3,755 ms |
| コンパイル使用メモリ | 76,904 KB |
| 実行使用メモリ | 41,956 KB |
| 最終ジャッジ日時 | 2024-11-08 21:29:55 |
| 合計ジャッジ時間 | 4,174 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 5 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int z = 0; z < t; z++) {
int d = sc.nextInt();
long x = sc.nextInt();
long y = sc.nextInt();
long ok = 0;
long ng = d + 1;
while (Math.abs(ok - ng) > 1) {
long mid = (ok + ng) / 2;
long nx = x + y * mid;
long ny = y - x * mid;
if (nx <= d && 0 <= ny) {
ok = mid;
} else {
ng = mid;
}
}
long bx = x + y * ok;
long by = y - x * ok;
long ans1 = Math.abs(x * by - bx * y);
ok = 0;
ng = d + 1;
while (Math.abs(ok - ng) > 1) {
long mid = (ok + ng) / 2;
long nx = x - y * mid;
long ny = y + x * mid;
if (0 <= nx && ny <= d) {
ok = mid;
} else {
ng = mid;
}
}
bx = x - y * ok;
by = y + x * ok;
long ans2 = Math.abs(x * by - bx * y);
System.out.println(Math.max(ans1, ans2));
}
sc.close();
}
}
ks2m