結果
問題 |
No.171 スワップ文字列(Med)
|
ユーザー |
|
提出日時 | 2015-07-07 15:08:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,141 bytes |
コンパイル時間 | 524 ms |
コンパイル使用メモリ | 61,024 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 01:30:04 |
合計ジャッジ時間 | 1,063 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 1 RE * 1 |
ソースコード
#include <algorithm> #include <iostream> #include <string> #include <vector> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; const ll mod = 573; ll invt[600] = {}; int tot = 0; int ap[26]; int solve(void) { int f3 = 0; int f191 = 0; ll acc = 1; REP(i, 1, tot + 1) { int v = i; while (v % 3 == 0) { v /= 3; f3++; } while (v % 191 == 0) { v /= 191; f191++; } acc = acc * v % mod; } REP(i, 0, 26) { REP(j, 1, ap[i] + 1) { int v = j; while (v % 3 == 0) { v /= 3; f3--; } while (v % 191 == 0) { v /= 191; f191--; } acc = acc * invt[v] % mod; } } REP(i, 0, f3) { acc = acc * 3 % mod; } REP(i, 0, f191) { acc = acc * 191 % mod; } return (acc + mod - 1) % mod; } int main(void){ REP(i, 1, mod) { if (__gcd(i, (int)mod) != 1) { continue; } REP(j, 1, mod) { if (i * j % mod == 1) { invt[i] = j; break; } } } string s; cin >> s; REP(i, 0, s.length()) { ap[s[i] - 'A']++; tot++; } cout << solve() << endl; }