結果
| 問題 |
No.2953 Maximum Right Triangle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-08 22:30:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 610 bytes |
| コンパイル時間 | 3,616 ms |
| コンパイル使用メモリ | 272,960 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 22:30:24 |
| 合計ジャッジ時間 | 4,139 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve();
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int tc; cin >> tc;
for (int tt = 0; tt < tc; tt++) solve();
return 0;
}
void solve() {
ll d, x, y; cin >> d >> x >> y;
if (x > y) swap(x, y);
if (x == 0) {
cout << d * y << "\n";
return;
}
ll dx = y / gcd(x, y), dy = x / gcd(x, y);
ll l = max(min((d - x) / dx, y / dy), min(x / dx, (d - y) / dy));
ll x0 = x - l * dx, y0 = y + l * dy;
ll ans = abs(x * y0 - y * x0);
cout << ans << "\n";
}