結果

問題 No.2493 K-th in L2 with L1
ユーザー rlangevinrlangevin
提出日時 2023-10-06 21:31:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 76,360 KB
最終ジャッジ日時 2023-10-06 21:31:56
合計ジャッジ時間 1,403 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,376 KB
testcase_01 AC 93 ms
76,156 KB
testcase_02 AC 95 ms
76,068 KB
testcase_03 AC 93 ms
76,360 KB
testcase_04 AC 70 ms
71,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

Q = int(input())
for _ in range(Q):
    L = []
    D, K = map(int, input().split())
    for x in range(1, D):
        y = D - x
        L.append((x**2 + y**2, x, y))
        L.append((x**2 + y**2, -x, y))
        L.append((x**2 + y**2, x, -y))
        L.append((x**2 + y**2, -x, -y))
    if D:
        L.append((D**2, D, 0))
        L.append((D**2, -D, 0))
        L.append((D**2, 0, D))
        L.append((D**2, 0, -D))
    else:
        L.append((0, 0, 0))
        
    L.sort()
    if K > len(L):
        print("No")
    else:
        print("Yes")
        print(L[K-1][1], L[K-1][2])    
    
        
0