結果
問題 | No.1927 AB-CD |
ユーザー |
|
提出日時 | 2022-05-06 22:06:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 1,745 ms |
コンパイル使用メモリ | 175,564 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 23:21:21 |
合計ジャッジ時間 | 3,096 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i=0; i<(n); i++)#define INF ((1LL<<62)-(1LL<<31))#define all(a) (a).begin(),(a).end()#define rall(a) (a).rbegin(),(a).rend()typedef long long ll;typedef pair<ll,ll> pl;const ll mod=998244353;ll modpow(ll n,ll r) {ll num=1;while(r) {if(r&1) num=num*n%mod;n=n*n%mod;r/=2;}return num;}ll comb(ll n,ll r) {ll x=1,y=1;for(ll i=0;i<r;i++) x=x*(n-i)%mod;for(ll i=1;i<=r;i++) y=y*i%mod;return x*modpow(y,mod-2)%mod;}int main() {ll n; string s;cin >> n >> s;map<char,ll> mp;for(char c:s) mp[c]++;ll m=mp['A']+mp['B'],k=mp['C']+mp['D'];cout << comb(m+k,k) << endl;return 0;}