結果

問題 No.1869 Doubling?
ユーザー bluemeganebluemegane
提出日時 2022-03-12 10:25:56
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 1,042 ms
コンパイル使用メモリ 65,732 KB
実行使用メモリ 25,884 KB
最終ジャッジ日時 2023-10-14 22:20:51
合計ジャッジ時間 5,761 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,576 KB
testcase_01 AC 64 ms
23,512 KB
testcase_02 AC 63 ms
19,464 KB
testcase_03 AC 64 ms
21,628 KB
testcase_04 AC 64 ms
23,440 KB
testcase_05 AC 63 ms
21,568 KB
testcase_06 AC 63 ms
21,400 KB
testcase_07 AC 64 ms
23,588 KB
testcase_08 AC 63 ms
21,404 KB
testcase_09 WA -
testcase_10 AC 63 ms
23,656 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 63 ms
21,512 KB
testcase_16 AC 63 ms
21,500 KB
testcase_17 AC 63 ms
21,456 KB
testcase_18 AC 64 ms
23,492 KB
testcase_19 AC 64 ms
23,560 KB
testcase_20 AC 64 ms
21,460 KB
testcase_21 AC 63 ms
21,468 KB
testcase_22 AC 64 ms
23,624 KB
testcase_23 AC 63 ms
19,460 KB
testcase_24 AC 63 ms
21,556 KB
testcase_25 AC 63 ms
21,468 KB
testcase_26 AC 64 ms
21,616 KB
testcase_27 AC 64 ms
21,452 KB
testcase_28 AC 63 ms
19,432 KB
testcase_29 AC 63 ms
21,556 KB
testcase_30 AC 63 ms
23,508 KB
testcase_31 AC 64 ms
21,612 KB
testcase_32 AC 64 ms
23,672 KB
testcase_33 AC 63 ms
23,540 KB
testcase_34 AC 63 ms
23,528 KB
testcase_35 AC 64 ms
21,528 KB
testcase_36 AC 64 ms
23,504 KB
testcase_37 AC 64 ms
23,612 KB
testcase_38 AC 63 ms
21,520 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 64 ms
21,756 KB
testcase_43 AC 62 ms
19,420 KB
testcase_44 AC 67 ms
23,728 KB
testcase_45 AC 62 ms
23,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = long.Parse(line[1]);
        getAns(n, m);
    }
    static void getAns(int n, long m)
    {
        var ans = new List<long>();
        ans.Add(m);
        while (m > 1)
        {
            m = m % 2 == 0 ? m / 2 : (m + 1) / 2;
            ans.Add(m);
        }
        if (ans.Count > n)
        {
            var ans2 = ans.OrderBy(x => x).Take(n).Sum();
            Console.WriteLine(ans2);
            return;
        }
        var res = ans.Sum();
        res += n - ans.Count;
        Console.WriteLine(res);
    }
}
0