結果

問題 No.2493 K-th in L2 with L1
ユーザー titia
提出日時 2023-10-06 21:40:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-26 15:52:53
合計ジャッジ時間 787 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter

Q=int(input())
for tests in range(Q):
    D,K=map(int,input().split())

    LIST=set()

    for i in range(-D,D+1):
        y=D-abs(i)

        LIST.add((i,y,i*i+y*y))
        LIST.add((i,-y,i*i+y*y))

    LIST=sorted(LIST,key=itemgetter(2))

    if K-1>=len(LIST):
        print("No")
    else:
        print("Yes")
        print(*LIST[K-1][:2])
0