結果

問題 No.2493 K-th in L2 with L1
コンテスト
ユーザー rlangevin
提出日時 2023-10-06 21:31:54
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 643 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 160 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 64,128 KB
最終ジャッジ日時 2026-04-03 17:30:30
合計ジャッジ時間 862 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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