結果

問題 No.2493 K-th in L2 with L1
ユーザー twooimptwooimp
提出日時 2023-10-06 21:53:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 176,664 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:54:01
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
    }
  }
}
0