結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
|
提出日時 | 2023-10-06 21:53:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 612 bytes |
コンパイル時間 | 1,852 ms |
コンパイル使用メモリ | 177,572 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-26 16:02:46 |
合計ジャッジ時間 | 2,282 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;using T=tuple<ll,ll,ll,ll>;int main(){ll q;cin>>q;while(q--){ll d,k;cin>>d>>k;vector<T> v;ll id=0;for(ll i=-100;i<=100;i++){for(ll j=-100;j<=100;j++){if(abs(i)+abs(j)==d){ll euc2=i*i+j*j;v.push_back(T(euc2,i,j,id));id++;}}}if(v.size()<k){cout<<"No"<<endl;}else{cout<<"Yes"<<endl;sort(v.begin(),v.end());ll ans1=get<1>(v[k-1]);ll ans2=get<2>(v[k-1]);cout<<ans1<<" "<<ans2<<endl;}}}