結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
|
提出日時 | 2023-10-06 21:33:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 72,128 KB |
最終ジャッジ日時 | 2024-07-26 15:48:43 |
合計ジャッジ時間 | 1,100 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
import syssys.setrecursionlimit(5*10**5)input = sys.stdin.readlinefrom collections import defaultdict, deque, Counterfrom heapq import heappop, heappushfrom bisect import bisect_left, bisect_rightfrom math import gcdq = int(input())dk = [list(map(int,input().split())) for i in range(q)]def eu(x,y):return x**2 + y**2for d,k in dk:pos = []if d == 0:if k == 1:print('Yes')print(0,0)else:print('No')continuefor 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')