結果
問題 | No.170 スワップ文字列(Easy) |
ユーザー |
![]() |
提出日時 | 2015-03-23 00:03:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 556 bytes |
コンパイル時間 | 560 ms |
コンパイル使用メモリ | 55,516 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 00:16:30 |
合計ジャッジ時間 | 1,390 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream>#include <string>using namespace std;void count(string S, int countList[26]) {int n = S.size();for (int j = 0; j < n; j++) {for (int i = 0; i < 26; i++) {if (S[j] == (char)(i+'A')) countList[i]++;}}}int main() {string S;cin >> S;int ans;int countList[26] = {};int fact[9];fact[0] = 1;for (int i = 1; i < 9; i++) {fact[i] = fact[i-1] * i;}count(S, countList);ans = fact[S.size()];for (int i = 0; i < 26; i++) {ans /= fact[countList[i]];}ans--;cout << ans << endl;return 0;}