結果

問題 No.897 compαctree
ユーザー bluemegane
提出日時 2021-05-27 15:35:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 110,916 KB
実行使用メモリ 26,364 KB
最終ジャッジ日時 2024-11-06 09:39:50
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Numerics;
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)
    {
        BigInteger 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