結果
問題 |
No.2 素因数ゲーム
|
ユーザー |
|
提出日時 | 2019-01-18 15:05:17 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,386 bytes |
コンパイル時間 | 3,609 ms |
コンパイル使用メモリ | 110,940 KB |
実行使用メモリ | 222,352 KB |
最終ジャッジ日時 | 2024-07-06 03:32:46 |
合計ジャッジ時間 | 8,156 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 WA * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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; } } }