結果
問題 |
No.2 素因数ゲーム
|
ユーザー |
|
提出日時 | 2019-01-18 15:16:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,582 bytes |
コンパイル時間 | 780 ms |
コンパイル使用メモリ | 104,320 KB |
実行使用メモリ | 211,968 KB |
最終ジャッジ日時 | 2024-09-21 15:29:44 |
合計ジャッジ時間 | 11,968 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 1 |
コンパイルメッセージ
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; int sumC = 0; foreach (int a in counter) { if (a == 1) sumA++; if (a == 2) sumB++; if (a > 2) sumC++; } if (sumA + sumB + sumC == 1) Console.WriteLine("Alice"); else if (sumC == 1 && sumB == 1 && sumA == 1) Console.WriteLine("Bob"); else if (sumA % 2 == 1) Console.WriteLine("Alice"); else if (sumA + sumB + sumC == 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; } } }