結果

問題 No.2493 K-th in L2 with L1
ユーザー twooimp2twooimp2
提出日時 2024-02-03 14:42:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 6,695 ms
コンパイル使用メモリ 309,104 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-03 14:42:09
合計ジャッジ時間 7,800 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using T=tuple<ld,ll,ll>;

void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main(){
  IO();
  ll q;
  cin>>q;
  while(q--){
    ll d,k;
    cin>>d>>k;
    vector<T> v;
    for(ll i=-d;i<=d;i++){
      for(ll j=-d;j<=d;j++){
        if(abs(i)+abs(j)==d){
          v.push_back(T(sqrt(i*i+j*j),i,j));
        }
      }
    }
    sort(v.begin(),v.end());
    if(v.size()<k){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
      cout<<get<1>(v[k-1])<<" "<<get<2>(v[k-1])<<endl;
    }
  }
}
0