結果
| 問題 | No.171 スワップ文字列(Med) | 
| コンテスト | |
| ユーザー |  alpha_virginis | 
| 提出日時 | 2016-10-24 21:17:26 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 6 ms / 1,000 ms | 
| コード長 | 611 bytes | 
| コンパイル時間 | 1,789 ms | 
| コンパイル使用メモリ | 165,840 KB | 
| 実行使用メモリ | 7,936 KB | 
| 最終ジャッジ日時 | 2024-11-24 02:48:45 | 
| 合計ジャッジ時間 | 2,104 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
#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;
}
            
            
            
        