結果

問題 No.2493 K-th in L2 with L1
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-06 21:45:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 68,432 KB
実行使用メモリ 24,156 KB
最終ジャッジ日時 2023-10-06 21:45:32
合計ジャッジ時間 2,225 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
23,988 KB
testcase_01 AC 76 ms
22,092 KB
testcase_02 AC 81 ms
22,128 KB
testcase_03 AC 79 ms
24,156 KB
testcase_04 AC 70 ms
21,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
    }
}
0