#ifndef INCLUDED_MAIN #define INCLUDED_MAIN #include __FILE__ #include using namespace atcoder; void solve(); void s() { int t = 1; cin>>t; rep(i, t)solve(); } using mint = modint998244353; void solve() { int d, k; cin >> d >> k; map s; map ma; for (int i = -d; i <= d; i++) { rep(k, 2) { int j = d - abs(i); j *= k ? 1 : -1; ld dis = i * i + j * j; s[dis]++; ma[dis] = { i,j }; } } int cnt = 0; for (auto x : s) { cnt += x.second; if (cnt >= k) { Yes cout << ma[x.fi].first<<" "< #pragma GCC optimize("O2") using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define drep(i,n) for(ll i=(long long)n;i>=0;i--) #define DREP(i,n,m) for(int i=n;i>=m;i--) #define REP(i,n,m) for(int i=n;i<(m);i++) #define fi first #define se second #define pb push_back #define mp make_pair #define ti tuple #define tl tuple #define mt make_tuple #define all(o) (o).begin(), (o).end() #define YESNO(bool) if(bool){cout<<"YES"<> #define vvl vector> #define vvvl vector #define vvvvl vector #define vi vector #define vp vector #define vpl vector #define ge(x,i) get(x) #define vl vector #define vs vector #define vvvi vector #define vb vector #define vvb vector> #define vvvb vec #define vs vector #define vvs vector #define vd vector #define vvd vector #define vld vector #define vvld vector #define pque priority_queue #define smpq(n) priority_queue,greater> #define bipq(n) priority_queue,less> #define sz(o) o.size() #define piii pair> #define ednl endl #define denl endl #define Endl endl #define Yes cout<<"Yes"<; using pll = pair; using plll = pair; using db = double; using ld = long double; template using vc = vector; template using vvc = vector>; template using vvvc = vector>; template using vvvvc = vector>; const long double pi = 3.1415926535897932384626433; const int inf = (1LL << 30) - 1; ll INF = (1LL << 62) - 1; const ll mod7 = 1e9 + 7; const ll mod9 = 998244353; template inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); } template inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); } int zero() { return 0; } ll zerol() { return 0l; } int plus(int a, int b) { return a + b; } int mini(int a, int b) { return min(a, b); } ll plusl(ll a, ll b) { return a + b; } ll minl(ll a, ll b) { return min(a, b); } int infi() { return inf; }; ll infl() { return INF; } template T sum(vector& a) { T ret = 0; rep(i, a.size()) ret += a[i]; return ret; } template void in(vector& a) { for (auto& x : a)cin >> x; } template void out(vector& a) { rep(i, a.size()) { if (i)cout << " "; cout << a[i]; } cout << endl; } //方向 int dx[4] = { -1,0,1,0 }; int dy[4] = { 0,1,0,-1 }; int sy[8] = { 1,-1,0,1,-1,1,0,-1 }; int dx1[6] = { 1,1,1,0,0,-1 }; int dy1[6] = { -1,0,1,-1,1,0 }; int dx2[6] = { -1,0,1,0,-1,-1 }; int dy2[6] = { 1,1,0,-1,-1,0 }; vi dx8 = { 1,1,1,0,0,-1,-1,-1 }; vi dy8 = { 1,-1,0,1,-1,1,0,-1 }; ull POW(ull a, ull b) { ull res = 1; rep(i, b) { res *= a; } return res; } vi kmp(string s) { vi a(s.size()); int j = -1; rep(i, s.size()) { while (j >= 0 && s[i] != s[j])j = a[j]; j++; a[i + 1] = j; } return a; } struct Unionfind { vector parent, size, mi; Unionfind(int n) : parent(n, -1), size(n, 1), mi(n, INF) {} void init() { rep(i, mi.size())mi[i] = i; } int root(int x) { if (parent[x] == -1) return x; return parent[x] = root(parent[x]); } bool same(int x, int y) { return root(x) == root(y); } int siz(int x) { return size[root(x)]; } void unite(int x, int y) { int rootX = root(x); int rootY = root(y); if (rootX == rootY) return; chmin(mi[rootX], mi[rootY]); chmin(mi[rootY], mi[rootX]); if (size[rootX] < size[rootY]) swap(rootX, rootY); parent[rootY] = rootX; size[rootX] += size[rootY]; } int m(int x) { return mi[root(x)]; } }; struct COM { vector fac, finv, inv; ll MOD = 1; COM(int n, ll mod) { fac.resize(n); finv.resize(n); inv.resize(n); MOD = mod; ll MAX = n; fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll com(int n,int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } }; vector> mat_mul(vector> a, vector> b, ll mod) { // 行列乗算 int n = a.size(); vector> res(n, vector(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { res[i][j] += a[i][k] * b[k][j]; res[i][j] %= mod; } } } return res; } vector> mat_pow(vector> a, ll b, ll mod) { // 行列累乗 int n = a.size(); vector> res(n, vector(n)); for (int i = 0; i < n; i++) res[i][i] = 1; while (b) { if (b & 1) res = mat_mul(res, a, mod); a = mat_mul(a, a, mod); b >>= 1; } return res; } //mod long long modpow(long long a, long long b, long long m) { if (a % m == 0)return 0; long long p = 1, q = a; q %= m; if (b < 0) return 0; for (int i = 0; i < 63; i++) { if ((b & (1LL << i)) != 0) { p *= q; p %= m; } q *= q; q %= m; } return p; } bool Find(string a, string b) { if (a.find(b) == string::npos) return false; return true; } ll modinv(ll n, ll mod) { return modpow(n, mod - 2, mod); } ll gcd(ll a, ll b) { if (a % b == 0) { if (b > 0) return b; else return -b; } else { return gcd(b, a % b); } } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } template tuple treediameter(vector>>& road, T n, T INF) { queue que; que.push(0); vb seen(n); vector mda(n); mda[0] = 0; seen[0] = true; T b; while (que.size()) { auto p = que.front(); que.pop(); for (auto x : road[p]) { if (!seen[x.fi]) { mda[x.fi] = mda[p] + x.se; b = x.fi; que.push(x.fi); seen[x.fi] = true; } } } T f = -INF; rep(i, n) { if (chmax(f, mda[i])) { b = i; } } que.push(b); rep(i, n)seen[i] = false; seen[b] = true; vector mdb(n); mdb[b] = 0; T a; while (que.size()) { auto p = que.front(); que.pop(); for (auto x : road[p]) { if (!seen[x.fi]) { mdb[x.fi] = mdb[p] + x.se; que.push(x.fi); seen[x.fi] = true; } } } T g = -INF; rep(i, n) { if (chmax(g, mdb[i])) { a = i; } } return make_tuple(a, b, mdb[a]); } void manhattanmst(vector points) { } ///// ///////////// #endif