結果
| 問題 |
No.2953 Maximum Right Triangle
|
| コンテスト | |
| ユーザー |
ripity
|
| 提出日時 | 2024-11-08 21:30:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 558 bytes |
| コンパイル時間 | 1,963 ms |
| コンパイル使用メモリ | 193,600 KB |
| 最終ジャッジ日時 | 2025-02-25 02:35:36 |
|
ジャッジサーバーID (参考情報) |
judge4 / 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();
}
ripity