結果

問題 No.2953 Maximum Right Triangle
ユーザー t98slider
提出日時 2024-11-10 14:37:00
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 2,431 ms
コンパイル使用メモリ 200,712 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-10 14:37:03
合計ジャッジ時間 2,912 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
ll D, x, y, ans = 0;
cin >> D >> x >> y;
auto calc = [&](ll x2, ll y2){
ans = max(ans, abs(x * y2 - y * x2));
};
ll g = gcd(x, y);
if(g == 0){
cout << 0 << '\n';
continue;
}
if(x == 0 || y == 0){
cout << max(x, y) * D << '\n';
continue;
}
ll dx = y / g, dy = x / g;
ll d = min(x / dx, (D - y) / dy);
calc(x - dx * d, y + dy * d);
d = min((D - x) / dx, y / dy);
calc(x + dx * d, y - dy * d);
cout << ans << '\n';
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0