結果

問題 No.2 素因数ゲーム
ユーザー HimatsubushinHimatsubushin
提出日時 2019-01-18 15:05:17
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,386 bytes
コンパイル時間 2,964 ms
コンパイル使用メモリ 103,248 KB
実行使用メモリ 217,680 KB
最終ジャッジ日時 2023-09-20 07:38:00
合計ジャッジ時間 11,919 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
18,592 KB
testcase_01 AC 54 ms
20,652 KB
testcase_02 AC 54 ms
20,680 KB
testcase_03 WA -
testcase_04 AC 54 ms
20,584 KB
testcase_05 AC 55 ms
22,740 KB
testcase_06 AC 116 ms
48,484 KB
testcase_07 WA -
testcase_08 AC 117 ms
47,428 KB
testcase_09 AC 562 ms
217,680 KB
testcase_10 AC 467 ms
190,500 KB
testcase_11 WA -
testcase_12 AC 246 ms
102,260 KB
testcase_13 AC 449 ms
182,812 KB
testcase_14 AC 91 ms
36,340 KB
testcase_15 AC 170 ms
70,068 KB
testcase_16 AC 335 ms
135,828 KB
testcase_17 AC 485 ms
194,224 KB
testcase_18 AC 522 ms
207,208 KB
testcase_19 AC 313 ms
127,184 KB
testcase_20 AC 400 ms
162,220 KB
testcase_21 AC 537 ms
211,964 KB
testcase_22 AC 489 ms
196,680 KB
testcase_23 AC 256 ms
105,512 KB
testcase_24 AC 521 ms
207,560 KB
testcase_25 AC 388 ms
157,988 KB
testcase_26 AC 289 ms
117,504 KB
testcase_27 AC 179 ms
72,448 KB
testcase_28 AC 322 ms
133,072 KB
testcase_29 AC 273 ms
113,028 KB
testcase_30 AC 258 ms
107,120 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 No002_素因数ゲーム
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] counter = Factoring(n);
            int sumA = 0;
            int sumB = 0;

            foreach (int a in counter)
            {
                if (a == 1)
                    sumA++;
                if (a > 1)
                    sumB++;
            }

            if (sumA + sumB == 1)
                Console.WriteLine("Alice");
            else if (sumA % 2 == 1)
                Console.WriteLine("Alice");
            else if (sumA + sumB == 3)
                Console.WriteLine("Alice");
            else if (sumB % 2 == 1)
                Console.WriteLine("Alice");
            else
                Console.WriteLine("Bob");
        }

        static int[] Factoring(int n)
        {
            int max = (n + n % 2) / 2;
            int[] number = new int[max];
            int[] counter = new int[max];

            number[0] = 2;
            for (int i = 3; i <= n; i += 2)
                number[i / 2] = i;

            for (int i = 0; i < max; i++)
            {
                while (n % number[i] == 0)
                {
                    n /= number[i];
                    counter[i]++;
                }
            }

            return counter;
        }
    }
}
0