結果
問題 | No.1958 Bit Game |
ユーザー |
|
提出日時 | 2022-05-27 22:07:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,276 ms / 2,000 ms |
コード長 | 1,318 bytes |
コンパイル時間 | 1,595 ms |
コンパイル使用メモリ | 170,340 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-09-20 15:57:26 |
合計ジャッジ時間 | 29,255 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using pll = pair<ll, ll>;#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)#define rep(i, n) drep(i, 0, n - 1)#define all(a) (a).begin(), (a).end()#define pb push_back#define fi first#define se secondconst ll MOD = 1000000007;const ll MOD2 = 998244353;const ll INF = 1LL << 60;const ll N_MAX = 2e5;ll pow_mod(ll x, ll n, ll mod){ll ret = 1;while(n > 0){if(n & 1) ret = (ret*x)%mod;x = x*x%mod;n >>=1;}return ret;}int main(){ll n, x, y;cin >> n >> x >> y;vector<ll> a(x), b(y);rep(i, x) cin >> a[i];rep(j, y) cin >> b[j];ll ans = 0;for(ll i=0; i<=18; i++){ll a_cnt = 0;ll b_cnt = 0;rep(j, x) if((a[j]>>i) & 1) a_cnt++;rep(j, y) if((b[j]>>i) & 1) b_cnt++;ll sa = 0;for(ll j=n; j>=1; j--){ll pre = (pow_mod(x, j-1, MOD2)*pow_mod(y, j-1, MOD2))%MOD2;ll mid = (a_cnt*b_cnt)%MOD2;ll pos = (pow_mod(x-a_cnt, n-j, MOD2)*pow_mod(b_cnt, n-j, MOD2))%MOD2;ll tmp = (pre*mid)%MOD2;sa += (tmp*pos)%MOD2;sa %= MOD2;}ans += (sa*pow_mod(2, i, MOD2))%MOD2;ans %= MOD2;}cout << ans << endl;}