結果
| 問題 | No.2493 K-th in L2 with L1 | 
| コンテスト | |
| ユーザー |  n_na | 
| 提出日時 | 2023-10-07 01:41:54 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 145 ms / 2,000 ms | 
| コード長 | 618 bytes | 
| コンパイル時間 | 289 ms | 
| コンパイル使用メモリ | 82,100 KB | 
| 実行使用メモリ | 77,708 KB | 
| 最終ジャッジ日時 | 2024-07-26 17:40:20 | 
| 合計ジャッジ時間 | 1,480 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 | 
ソースコード
import bisect
Q = int(input())
for _ in range(Q):
    d,k = map(int,input().split())
    A = []
    P = []
    for y in range(-100,101,1):
        for x in range(-100,101,1):
            if abs(y) + abs(x) == d:
                e = pow(x*x + y*y, 0.5)
                A.append(e)
                P.append((y,x))
    A.sort()
    ans = "No"
    for y,x in P:
        e = pow(x*x + y*y, 0.5)
        L = bisect.bisect_left(A, e)
        R = bisect.bisect_right(A, e)
        if L < k and k <= R:
            ans = "Yes"
            c = [y,x]
            break
    print(ans)
    if ans == "Yes":
        print(*c)
    
            
            
            
        