結果

問題 No.2493 K-th in L2 with L1
ユーザー n_nan_na
提出日時 2023-10-07 01:41:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 87,368 KB
実行使用メモリ 78,788 KB
最終ジャッジ日時 2023-10-07 01:41:56
合計ジャッジ時間 2,038 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
77,820 KB
testcase_01 AC 172 ms
78,788 KB
testcase_02 AC 162 ms
78,436 KB
testcase_03 AC 185 ms
78,664 KB
testcase_04 AC 101 ms
76,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
    
0