#include #include using namespace std; using namespace atcoder; constexpr int mod = 998244353; long long power_mod(long long a, long long p) { if (p==0) return 1LL; a %= mod; if (a<0) a += mod; if (p<0) { assert(gcd(a,mod)==1); p = (p%(mod-1))+mod-1; } long long result = 1; long long b = a; while (p>0) { if (p&1LL) result = result*b%mod; b = b*b%mod; p >>= 1; } return result; } vector factorial; vector fact_inv; void make_factorial(int n, bool make_inv = true) { assert(n>=0); if (make_inv) assert(n0; i--) { fact_inv[i-1] = fact_inv[i]*i%mod; } } long long comb(int n, int r) { if (r<0) return 0; if (r>n) return 0; long long result = factorial[n]; result *= fact_inv[r]; result %= mod; result *= fact_inv[n-r]; result %= mod; return result; } long long comb_inv(int n, int r) { assert(r>=0); assert(r<=n); assert(n> n >> s; //////////////// 出力変数定義 //////////////// int result = 0; //////////////////// 処理 //////////////////// make_factorial(n); int counter0 = 0; int counter1 = 0; for (char c : s) { if (c=='A'||c=='B') counter0++; else counter1++; } result = comb(counter0+counter1,counter0); //////////////////// 出力 //////////////////// cout << result << endl; //////////////////// 終了 //////////////////// return 0; }