結果

問題 No.2493 K-th in L2 with L1
ユーザー hiro1729
提出日時 2023-10-06 21:28:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 65,940 KB
最終ジャッジ日時 2024-07-26 15:43:40
合計ジャッジ時間 911 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
	d, k = map(int, input().split())
	if d == 0:
		if k > 1:
			print("No")
		else:
			print("Yes")
			print(0, 0)
	else:
		if k > 4 * d:
			print("No")
		else:
			print("Yes")
			a = []
			for i in range(-d, d + 1):
				if i == -d or i == d:
					a.append((i, 0))
				else:
					a.append((i, min(d + i, d - i)))
					a.append((i, -min(d + i, d - i)))
			a.sort(key = lambda x: x[0] * x[0] + x[1] * x[1])
			print(*a[k - 1])
0