結果

問題 No.2 素因数ゲーム
ユーザー HimatsubushinHimatsubushin
提出日時 2019-01-18 15:04:04
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,577 bytes
コンパイル時間 3,472 ms
コンパイル使用メモリ 105,648 KB
実行使用メモリ 54,896 KB
最終ジャッジ日時 2023-09-20 07:36:28
合計ジャッジ時間 9,252 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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++;
            }

            foreach (int a in counter)
                Console.Write(a.ToString() + ", ");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            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