結果

問題 No.897 compαctree
ユーザー bluemeganebluemegane
提出日時 2021-05-27 15:28:39
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 1,878 ms
コンパイル使用メモリ 103,296 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-04-24 02:49:12
合計ジャッジ時間 1,995 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
17,792 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 21 ms
17,792 KB
testcase_07 AC 21 ms
17,920 KB
testcase_08 AC 22 ms
17,792 KB
testcase_09 AC 22 ms
17,664 KB
testcase_10 AC 22 ms
17,792 KB
testcase_11 AC 22 ms
17,792 KB
testcase_12 AC 23 ms
17,792 KB
testcase_13 AC 21 ms
17,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var q = int.Parse(Console.ReadLine().Trim());
        while (q-- > 0)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            long k = int.Parse(line[1]);
            if (k == 1) Console.WriteLine(n - 1);
            else getAns(n, k);
        }
    }
    static void getAns(int n, long k)
    {
        var a = k * k;
        var p = 2;
        while (true)
        {
            var w = (a - 1) / (k - 1);
            if (w > n) { Console.WriteLine(p - 1); return; }
            a *= k;
            p++;
        }
    }
}
0