結果

問題 No.2493 K-th in L2 with L1
ユーザー hiro1729hiro1729
提出日時 2023-10-06 21:28:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 76,560 KB
最終ジャッジ日時 2023-10-06 21:28:04
合計ジャッジ時間 1,412 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,556 KB
testcase_01 AC 91 ms
76,448 KB
testcase_02 AC 88 ms
76,396 KB
testcase_03 AC 86 ms
76,560 KB
testcase_04 AC 70 ms
71,524 KB
権限があれば一括ダウンロードができます

ソースコード

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