結果
| 問題 | No.2493 K-th in L2 with L1 | 
| コンテスト | |
| ユーザー |  rlangevin | 
| 提出日時 | 2023-10-06 21:31:54 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 65 ms / 2,000 ms | 
| コード長 | 643 bytes | 
| コンパイル時間 | 466 ms | 
| コンパイル使用メモリ | 82,236 KB | 
| 実行使用メモリ | 64,384 KB | 
| 最終ジャッジ日時 | 2024-07-26 15:48:18 | 
| 合計ジャッジ時間 | 1,195 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 | 
ソースコード
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])    
    
        
            
            
            
        