結果

問題 No.2 素因数ゲーム
ユーザー HimatsubushinHimatsubushin
提出日時 2019-12-18 15:46:19
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 382 ms / 5,000 ms
コード長 708 bytes
コンパイル時間 1,942 ms
コンパイル使用メモリ 66,756 KB
実行使用メモリ 22,728 KB
最終ジャッジ日時 2023-09-20 18:02:56
合計ジャッジ時間 5,152 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
20,836 KB
testcase_01 AC 53 ms
22,592 KB
testcase_02 AC 53 ms
20,736 KB
testcase_03 AC 53 ms
22,656 KB
testcase_04 AC 53 ms
22,664 KB
testcase_05 AC 53 ms
20,544 KB
testcase_06 AC 53 ms
20,612 KB
testcase_07 AC 53 ms
22,728 KB
testcase_08 AC 62 ms
22,652 KB
testcase_09 AC 53 ms
20,552 KB
testcase_10 AC 53 ms
20,696 KB
testcase_11 AC 54 ms
20,712 KB
testcase_12 AC 53 ms
20,772 KB
testcase_13 AC 54 ms
20,680 KB
testcase_14 AC 53 ms
22,724 KB
testcase_15 AC 54 ms
22,672 KB
testcase_16 AC 53 ms
20,560 KB
testcase_17 AC 55 ms
22,664 KB
testcase_18 AC 53 ms
20,596 KB
testcase_19 AC 235 ms
20,652 KB
testcase_20 AC 174 ms
20,596 KB
testcase_21 AC 382 ms
20,684 KB
testcase_22 AC 62 ms
22,644 KB
testcase_23 AC 53 ms
20,820 KB
testcase_24 AC 53 ms
20,660 KB
testcase_25 AC 60 ms
18,552 KB
testcase_26 AC 53 ms
18,608 KB
testcase_27 AC 54 ms
20,828 KB
testcase_28 AC 53 ms
20,712 KB
testcase_29 AC 53 ms
22,620 KB
testcase_30 AC 54 ms
20,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

namespace No002_素因数ゲーム
{
    class Program
    {
        static void Main(string[] args)
        {
            int result = 0;
            int n = int.Parse(Console.ReadLine());

            result ^= fact(ref n, 2);

            for (int i = 3; i <= n; i += 2)
                result ^= fact(ref n, i);

            if (result == 0)
                Console.WriteLine("Bob");
            else
                Console.WriteLine("Alice");
        }

        static int fact(ref int n, int d)
        {
            int count = 0;

            while (n % d == 0)
            {
                count++;
                n /= d;
            }

            return count;
        }
    }
}
0