結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
|
提出日時 | 2023-10-06 21:45:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 1,216 bytes |
コンパイル時間 | 3,657 ms |
コンパイル使用メモリ | 116,568 KB |
実行使用メモリ | 20,096 KB |
最終ジャッジ日時 | 2024-07-26 15:56:13 |
合計ジャッジ時間 | 3,215 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using static System.Console;using System.Linq;using System.Collections.Generic;class Program{static int NN => int.Parse(ReadLine());static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();public static void Main(){Solve();}static void Solve(){var q = NN;var ans = new List<string>();for (var i = 0; i < q; ++i){var c = NList;var (d, k) = (c[0], c[1]);var goods = new List<(int x, int y)>();for (var j = -d; j <= d; ++j){goods.Add((j, d - Math.Abs(j)));if (-d < j && j < d) goods.Add((j, Math.Abs(j) - d));}goods.Sort((l, r) => Euc(l).CompareTo(Euc(r)));if (k > goods.Count){ans.Add("No");}else{ans.Add("Yes");ans.Add($"{goods[k - 1].x} {goods[k - 1].y}");}}WriteLine(string.Join("\n", ans));}static int Euc((int x, int y) a){return a.x * a.x + a.y * a.y;}}