結果

問題 No.2493 K-th in L2 with L1
ユーザー GOTKAKOGOTKAKO
提出日時 2023-10-06 21:36:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 173,224 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:36:36
合計ジャッジ時間 2,255 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int Q; cin >> Q;
    for(int i=0; i<Q; i++){
        int D,K; cin >> D >> K;
        if(D == 0 && K == 1){cout << "Yes" << endl << 0 << " " << 0 << endl; continue;}
        if(D*4 < K){cout << "No" << endl; continue;}
        

        vector<pair<double,int>> dist;
        for(int k=0; k<D; k++){
            double x = k, y = D-k;
            for(int l=0; l<4; l++) dist.push_back({x*x+y*y,k});
        }
        sort(dist.begin(),dist.end());
        
        int ansx = dist.at(K-1).second;
        cout << "Yes" << endl;
        cout << ansx << " " << D-ansx << endl;
    }
}
0