結果

問題 No.2953 Maximum Right Triangle
ユーザー syuya2036
提出日時 2024-11-09 01:49:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 768 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 167,340 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-09 01:49:18
合計ジャッジ時間 2,539 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

long gcd(long n1, long n2) {
    long ret = n1 % n2;
    return (ret == 0) ? n2 : gcd(n2, ret);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T; cin>>T;
    while(T--) {
        long x, y, D;
        cin>>D>>x>>y;
        long ans = 0;
        long X = x / gcd(x, y);
        long Y = y / gcd(x, y);
        {
            long mt = min((D-y)/X, x/Y);
            long i = y+mt*X;
            long j = x-mt*Y;
            ans = max(ans, abs(x*i - y*j));
        }
        {
            long mt = min((D-x)/Y, y/X);
            long i = y-mt*X;
            long j = x+mt*Y;
            ans = max(ans, abs(x*i - y*j));
        }
        cout<<ans<<endl;
    }
}

0