結果
問題 | No.2953 Maximum Right Triangle |
ユーザー |
![]() |
提出日時 | 2024-11-08 21:30:18 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 2,165 ms |
コンパイル使用メモリ | 200,960 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 21:30:22 |
合計ジャッジ時間 | 2,612 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;void solve() {ll D, x, y;cin >> D >> x >> y;if(x == 0 && y == 0) {cout << 0 << endl;}else if(x == 0) {cout << y * D << endl;}else if(y == 0) {cout << x * D << endl;}else {if(x < y) swap(x, y);const ll g = gcd(x, y);const ll p = x / g;const ll q = y / g;const ll a = x / q;const ll b = (D - y) / p;cout << (p * p + q * q) * g * min(a, b) << endl;}}int main() {int T;cin >> T;while(T--) solve();}