結果
問題 |
No.170 スワップ文字列(Easy)
|
ユーザー |
![]() |
提出日時 | 2016-10-08 02:40:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 783 bytes |
コンパイル時間 | 445 ms |
コンパイル使用メモリ | 60,748 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 00:43:32 |
合計ジャッジ時間 | 1,149 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include<iostream> #include<math.h> #include<string> using namespace std; int kaijo(int a){ int an = 1; if (a == 0){ an = 1; } else{ for (int i = 1; i <= a; i++){ an *= i; } } return an; } int main(){ string s; cin >> s; int cnt[8] = {0}; int i = 0; int in; int ans; int bunbo=1; int bunshi = 0; int l = s.length(); while (i<l){ if (s[i] == '.'){ i++; continue; } in = i; cnt[i]++; while (1){ in = s.find(s[i], in + 1); if (in == -1){ break; } else{ cnt[i]++; s[in] = '.'; } } // cout << s << endl; i++; } for (int i = 0; i < 8; i++){ bunshi += cnt[i]; bunbo *= kaijo(cnt[i]); } ans = kaijo(bunshi) / bunbo - 1; cout << ans << endl; return 0; }