結果

問題 No.103 素因数ゲーム リターンズ
ユーザー te-shte-sh
提出日時 2016-09-05 16:02:12
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 975 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 115,348 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 21:56:20
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 1 ms
4,368 KB
testcase_07 AC 1 ms
4,372 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 1 ms
4,372 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 1 ms
4,372 KB
testcase_22 AC 2 ms
4,368 KB
testcase_23 AC 2 ms
4,372 KB
testcase_24 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto n = readln.chomp.to!int;
  auto mi = readln.split.map!(to!int);

  auto pi = primes(mi.reduce!(max));
  auto qi = mi.map!(m => calc(m, pi)).reduce!("a ~ b");

  writeln(qi.map!("a % 3").reduce!("a ^ b") == 0 ? "Bob" : "Alice");
}

int[] calc(int n, int[] pi)
{
  int[] r;
  int i = 0;

  while (n > 1) {
    auto s = 0;
    while (n % pi[i] == 0) {
      s += 1;
      n /= pi[i];
    }
    if (s > 0) r ~= s;
    i += 1;
  }

  return r;
}

int[] primes(int n)
{
  auto sieve = new bool[](n + 1);
  sieve[0..2] = false;
  sieve[2..$] = true;

  foreach (p; 2..n.to!real.sqrt.to!int + 1)
    if (sieve[p])
      foreach (q; iota(p * 2, n + 1, p))
        sieve[q] = false;

  return sieve.enumerate
    .filter!("a[1]")
    .map!("a[0]").map!(to!int).array;
}
0