結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
![]() |
提出日時 | 2023-10-06 23:02:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 884 bytes |
コンパイル時間 | 1,686 ms |
コンパイル使用メモリ | 202,904 KB |
最終ジャッジ日時 | 2025-02-17 05:30:14 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include<bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);int q;cin>>q;while(q--){ll d,k;cin>>d>>k;if(d==0 && k==1){cout<<"Yes"<<endl;cout<<0<<" "<<0<<endl;continue;}if(d==0){cout<<"No"<<endl;continue;}vector<pair<ll,pair<ll,ll>>> P;for(ll i=1;i<=d;i++){ll dis=i*i+(d-i)*(d-i);P.push_back({dis,{i,d-i}});P.push_back({dis,{-i,-d+i}});P.push_back({dis,{-i,d-i}});P.push_back({dis,{i,-d+i}});}if((int)P.size()<k){cout<<"No"<<endl;continue;}cout<<"Yes"<<endl;sort(ALL(P));cout<<P[k-1].second.first<<" "<<P[k-1].second.second<<endl;}return 0;}