結果
| 問題 | No.2493 K-th in L2 with L1 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-10-06 21:36:33 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 706 bytes | 
| コンパイル時間 | 1,822 ms | 
| コンパイル使用メモリ | 174,220 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-26 15:51:21 | 
| 合計ジャッジ時間 | 2,229 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 | 
ソースコード
#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;
    }
}
            
            
            
        