結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー water_is_Iwater_is_I
提出日時 2017-03-16 23:11:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 3,989 ms
コンパイル使用メモリ 101,208 KB
実行使用メモリ 22,756 KB
最終ジャッジ日時 2023-09-17 05:24:37
合計ジャッジ時間 4,225 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,688 KB
testcase_01 AC 55 ms
20,584 KB
testcase_02 AC 54 ms
18,576 KB
testcase_03 AC 55 ms
22,640 KB
testcase_04 AC 55 ms
20,804 KB
testcase_05 AC 55 ms
20,704 KB
testcase_06 AC 55 ms
20,652 KB
testcase_07 AC 54 ms
20,616 KB
testcase_08 AC 56 ms
22,756 KB
testcase_09 AC 54 ms
20,620 KB
testcase_10 AC 55 ms
20,712 KB
testcase_11 AC 55 ms
20,768 KB
testcase_12 AC 56 ms
20,728 KB
testcase_13 AC 55 ms
18,624 KB
testcase_14 AC 55 ms
20,568 KB
testcase_15 AC 55 ms
20,732 KB
testcase_16 AC 54 ms
18,556 KB
testcase_17 AC 55 ms
20,588 KB
testcase_18 AC 55 ms
20,596 KB
testcase_19 AC 54 ms
20,540 KB
testcase_20 AC 54 ms
20,620 KB
testcase_21 AC 55 ms
20,708 KB
testcase_22 AC 55 ms
20,800 KB
testcase_23 AC 55 ms
20,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder_001 {
    class Program {
        static void Main(string[] args) {
            string NS = Console.ReadLine();
            int N = Int32.Parse(NS);
            Console.WriteLine(Count(N));//N渡して
            
        }

        static int pocket(int bis) {
            return bis * 2;
        }

        static int Count(int N) {
            int bis = 1;
            int i = 0;
            while (N > pocket(bis)) {
                bis = pocket(bis);
                i++;
            }
            if (N - bis == 0) return i;
            int N2 = N - bis;
            if (N2 % 2 == 0 || N2 % 2 == 1) {
                i++;
            }
            return i;
        }
    }
}

0