結果

問題 No.1751 Fortune Nim
ユーザー torisasami4
提出日時 2021-11-04 04:23:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 5,058 ms
コンパイル使用メモリ 250,020 KB
最終ジャッジ日時 2025-01-25 11:17:05
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    long long sum = 0;
    int x = 0;
    rep(i, n) sum += a[i], x ^= a[i];
    long long t;
    if(x != 0) {
        int m = 2e9;
        rep(i, n) m = min(m, (a[i] ^ x) - a[i]);
        t = sum + m + 1;
    }
    else
        t = sum;
    cout << (((mint)1 - ((mint)(-1) / 3).pow(t)) / 2).val() << endl;
}
0