結果

問題 No.171 スワップ文字列(Med)
ユーザー te-shte-sh
提出日時 2016-09-07 17:25:21
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 892 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 115,236 KB
実行使用メモリ 6,696 KB
最終ジャッジ日時 2023-09-02 21:59:20
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 4 ms
6,688 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 4 ms
6,696 KB
testcase_07 AC 5 ms
6,668 KB
testcase_08 AC 5 ms
6,636 KB
testcase_09 AC 5 ms
6,696 KB
testcase_10 AC 1 ms
4,372 KB
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 1 ms
4,368 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.regex, std.conv, std.stdio, std.typecons;

const auto mod = 573;

void main()
{
  auto s = readln.chomp.map!(to!int).array;
  s.sort();
  auto gi = s.group.map!("a[1]").array;


  int[] primeFactors(int n) {
    auto pi = new int[](s.length + 1);
    auto p = 2;
    while (n > 1) {
      if (n % p == 0) {
        pi[p] += 1;
        n /= p;
      } else {
        p += (p == 2 ? 1 : 2);
      }
    }
    return pi;
  }

  auto pi = new int[](s.length + 1);
  foreach (i; 1..s.length + 1)
    pi[] += primeFactors(i.to!int)[];

  foreach (g; gi)
    foreach (h; 1..g + 1)
      pi[] -= primeFactors(h)[];

  auto r = 1;
  foreach (i, p; pi)
    foreach (_; 0..p)
      r = (r * i) % mod;

  writeln(r == 0 ? mod - 1 : r - 1);
}
0