結果

問題 No.171 スワップ文字列(Med)
ユーザー alpha_virginisalpha_virginis
提出日時 2016-10-24 21:17:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 611 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 164,360 KB
実行使用メモリ 7,696 KB
最終ジャッジ日時 2023-08-15 18:38:48
合計ジャッジ時間 1,990 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,572 KB
testcase_01 AC 3 ms
7,548 KB
testcase_02 AC 3 ms
7,600 KB
testcase_03 AC 3 ms
7,696 KB
testcase_04 AC 4 ms
7,584 KB
testcase_05 AC 4 ms
7,588 KB
testcase_06 AC 3 ms
7,612 KB
testcase_07 AC 3 ms
7,640 KB
testcase_08 AC 4 ms
7,676 KB
testcase_09 AC 3 ms
7,548 KB
testcase_10 AC 3 ms
7,588 KB
testcase_11 AC 3 ms
7,604 KB
testcase_12 AC 4 ms
7,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int nCr[1024][1024];

void init_nCr() {
  nCr[0][0] = 1;
  for(int i = 1; i < 1024; ++i) {
    nCr[i][0] = nCr[i][i] = 1;
    for(int j = 1; j < i; ++j) {
      nCr[i][j] = (nCr[i-1][j-1] + nCr[i-1][j]) % 573;
    }
  }
}

int main() {
  init_nCr();
  int count[26] = {};
  char buf[1024];
  scanf("%s", buf);
  int n = strlen(buf);
  for(int i = 0; i < n; ++i) {
    count[buf[i]-'A'] += 1;
  }
  int rem = n;
  int res = 1;
  for(int i = 0; i < 26; ++i) {
    res = (res * nCr[rem][count[i]]) % 573;
    rem -= count[i];
  }
  printf("%d\n", (res + 573 - 1) % 573);
  
  return 0;
}
0