結果
| 問題 |
No.2493 K-th in L2 with L1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-04 13:46:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 856 bytes |
| コンパイル時間 | 3,207 ms |
| コンパイル使用メモリ | 164,208 KB |
| 最終ジャッジ日時 | 2025-02-17 19:11:19 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
void solve(){
int d,k;
cin >> d >> k;
vector<pair<int,pair<int,int>>> a;
for (int x = -d; x <= d;x++){
for (int y = -d; y <= d;y++){
if (abs(x)+abs(y) == d){
a.push_back({x*x+y*y,{x,y}});
}
}
}
sort(a.begin(),a.end());
//cout << "size:" << a.size() << endl;
if (k <= a.size()){
cout << "Yes\n";
cout << a[k-1].second.first << " " << a[k-1].second.second << endl;
}
else cout << "No\n";
return;
}
int main(){
int q;
cin >> q;
while(q--){
solve();
}
return 0;
}