結果

問題 No.2493 K-th in L2 with L1
ユーザー sabbir ahmed sabbirsabbir ahmed sabbir
提出日時 2023-10-06 22:40:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 68,396 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-10-06 22:40:40
合計ジャッジ時間 1,709 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int Q;
    cin >> Q;

    for (int i = 0; i < Q; i++) {
        int D, K;
        cin >> D >> K;

        bool found = false;
        for (int x = 0; x <= D; x++) {
            int y = sqrt(D * D - x * x);
            if (x * x + y * y == D * D && x + y <= K) {
                cout << "Yes\n" << x << " " << y << endl;
                found = true;
                break;
            }
        }

        if (!found) {
            cout << "No" << endl;
        }
    }

    return 0;
}
0