結果
問題 |
No.2953 Maximum Right Triangle
|
ユーザー |
|
提出日時 | 2024-11-08 22:26:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 539 bytes |
コンパイル時間 | 3,696 ms |
コンパイル使用メモリ | 273,056 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 22:26:36 |
合計ジャッジ時間 | 4,693 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 RE * 3 |
ソースコード
#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); 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"; }