結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー nanophoto12nanophoto12
提出日時 2014-11-01 16:46:14
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 850 bytes
コンパイル時間 3,222 ms
コンパイル使用メモリ 99,664 KB
実行使用メモリ 22,888 KB
最終ジャッジ日時 2023-08-29 00:09:29
合計ジャッジ時間 4,417 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,588 KB
testcase_01 AC 55 ms
20,756 KB
testcase_02 AC 55 ms
20,668 KB
testcase_03 AC 55 ms
22,888 KB
testcase_04 AC 55 ms
20,844 KB
testcase_05 AC 55 ms
22,708 KB
testcase_06 AC 56 ms
22,708 KB
testcase_07 AC 56 ms
20,732 KB
testcase_08 AC 56 ms
20,740 KB
testcase_09 AC 56 ms
22,632 KB
testcase_10 AC 55 ms
20,724 KB
testcase_11 AC 55 ms
20,592 KB
testcase_12 AC 55 ms
20,820 KB
testcase_13 AC 55 ms
20,876 KB
testcase_14 AC 55 ms
22,812 KB
testcase_15 AC 55 ms
20,692 KB
testcase_16 AC 55 ms
20,652 KB
testcase_17 AC 55 ms
18,548 KB
testcase_18 AC 55 ms
20,688 KB
testcase_19 AC 55 ms
22,732 KB
testcase_20 AC 56 ms
20,732 KB
testcase_21 AC 57 ms
22,704 KB
testcase_22 AC 56 ms
20,664 KB
testcase_23 AC 56 ms
20,740 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        if (n == 1)
        {
            Console.WriteLine(0);
            return;
        }
        bool[] bits = new bool[32];
        int maxBits = 0;
        for(int i = 0; i < 32;i++)
        {
            if ((n & (1 << i)) == 1 << i)
            {
                bits[i] = true;
                maxBits = Math.Max(maxBits, i);
            }
        }
        bool hasMore = false;
        for (int i = maxBits-1; i >= 0; i--)
        {
            if (bits[i])
            {
                hasMore = true;
            }
        }
        if (hasMore)
        {
            Console.WriteLine(maxBits+1);
            return;
        }
        Console.WriteLine(maxBits);
    }
}
0