結果

問題 No.1286 Stone Skipping
ユーザー bluemeganebluemegane
提出日時 2020-11-14 16:08:55
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 976 bytes
コンパイル時間 774 ms
コンパイル使用メモリ 63,320 KB
実行使用メモリ 22,844 KB
最終ジャッジ日時 2023-09-30 05:12:26
合計ジャッジ時間 3,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
20,720 KB
testcase_01 WA -
testcase_02 AC 49 ms
22,752 KB
testcase_03 AC 50 ms
22,708 KB
testcase_04 AC 51 ms
20,648 KB
testcase_05 AC 47 ms
20,644 KB
testcase_06 AC 48 ms
22,844 KB
testcase_07 AC 49 ms
20,816 KB
testcase_08 AC 51 ms
22,760 KB
testcase_09 AC 53 ms
22,684 KB
testcase_10 AC 52 ms
22,720 KB
testcase_11 AC 50 ms
20,724 KB
testcase_12 AC 49 ms
18,680 KB
testcase_13 AC 52 ms
20,716 KB
testcase_14 AC 49 ms
20,712 KB
testcase_15 AC 49 ms
22,724 KB
testcase_16 AC 50 ms
20,736 KB
testcase_17 AC 51 ms
22,680 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 48 ms
20,756 KB
testcase_21 AC 50 ms
22,804 KB
testcase_22 AC 48 ms
20,688 KB
testcase_23 AC 49 ms
20,664 KB
testcase_24 AC 50 ms
22,692 KB
testcase_25 AC 48 ms
18,600 KB
testcase_26 AC 54 ms
20,764 KB
testcase_27 AC 53 ms
20,640 KB
testcase_28 AC 52 ms
20,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        getAns(n);
    }
    static void getAns (long n)
    {
        var ans = long.MaxValue;
        for (int k = 0; k < 65; k++)
        {
            var w = BS(n, k);
            if (w != -1) ans = Min(ans, w);
        }
        Console.WriteLine(ans);
    }
    static long BS (long targ, int k)
    {
        var ng = 1L;
        var ok = targ;
        while (ok - ng > 1)
        {
            var mid = ng + (ok - ng) / 2;
            var w = calc(mid, k);
            if (w == targ) return mid;
            else if (w > targ) ok = mid;
            else ng = mid;
        }
        return -1;
    }
    static long calc (long n , int k)
    {
        var res = n;
        var p = 1;
        while (p < k && n >0)
        {
            n /= 2;
            res += n;
            p++;
        }
        return res;
    }
}
0