結果

問題 No.2493 K-th in L2 with L1
ユーザー 👑 H20H20
提出日時 2023-10-06 22:57:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 76,532 KB
最終ジャッジ日時 2023-10-06 22:57:05
合計ジャッジ時間 1,314 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,228 KB
testcase_01 AC 87 ms
76,492 KB
testcase_02 AC 86 ms
76,532 KB
testcase_03 AC 86 ms
76,516 KB
testcase_04 AC 68 ms
71,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q = int(input())
DK = [list(map(int, input().split())) for _ in range(Q)]
for d,k in DK:
    if d==0:
        if k==1:
            print('Yes')
            print(0,0)
        else:
            print('No')
    else:
        if 1<=k<=d*4:
            ANS = []
            for x in range(-d,d+1):
                y=d-abs(x)
                ANS.append([x**2+y**2,x,y])
                if abs(x)!=d:
                    y*=-1
                    ANS.append([x**2+y**2,x,y])
            ANS.sort()
            print('Yes')
            print(*ANS[k-1][1:])
        else:
            print('No')
0