結果

問題 No.2493 K-th in L2 with L1
ユーザー flygonflygon
提出日時 2023-10-06 21:33:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 77,408 KB
最終ジャッジ日時 2023-10-06 21:33:17
合計ジャッジ時間 1,750 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
76,248 KB
testcase_01 AC 121 ms
77,396 KB
testcase_02 AC 118 ms
77,044 KB
testcase_03 AC 118 ms
77,408 KB
testcase_04 AC 99 ms
71,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

q = int(input())
dk = [list(map(int,input().split())) for i in range(q)]

def eu(x,y):
    return x**2 + y**2


for d,k in dk:
    pos = []
    if d == 0:
        if k == 1:
            print('Yes')
            print(0,0)
        else:
            print('No')
        continue
    for x in range(d+1):
        y = d-abs(x)
        pos.append([eu(x,y),x*1000+y])
        pos.append([eu(x,y),x*1000+y])
        if x != 0 and y != 0:
            pos.append([eu(x,y),x*1000+y])
            pos.append([eu(x,y),x*1000+y])
    pos.sort()
    if len(pos) >= k >= 1:
        ans = pos[k-1][1]
        print('Yes')
        print(ans//1000, ans%1000)
    else:
        print('No')
0