結果

問題 No.1751 Fortune Nim
ユーザー dekomori_sanaedekomori_sanae
提出日時 2022-03-04 15:33:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,629 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 15:21:24
合計ジャッジ時間 4,500 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 59 ms
4,380 KB
testcase_17 AC 49 ms
4,376 KB
testcase_18 AC 67 ms
4,376 KB
testcase_19 AC 47 ms
4,380 KB
testcase_20 AC 72 ms
4,376 KB
testcase_21 AC 56 ms
4,380 KB
testcase_22 AC 73 ms
4,376 KB
testcase_23 AC 63 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 75 ms
4,376 KB
testcase_29 AC 75 ms
4,376 KB
testcase_30 AC 75 ms
4,376 KB
testcase_31 AC 75 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;

const ll MAX = 10;

ll inv[MAX];  // inv[i] : iの逆数のmod

void init() {
    inv[0] = inv[1] = 1;
    for(ll i = 1; i < MAX; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
    }
}

// a^n (mod.MOD)を求める。計算量はO(logn)
ll modpow(ll a, ll n, ll MOD = mod) {
    if(n == 0) {
        return 1;
    }
    if(n % 2 == 1) {
        return a * modpow(a, n-1, MOD) % MOD;
    }
    return modpow(a, n/2, MOD) * modpow(a, n/2, MOD) % MOD;
}

int main() {
    ll n;
    cin >> n;

    init();

    if(n == 1) {
        ll a;
        cin >> a;
        out(665496236);
        re0;
    }

    ll x = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        x += a;
    }

    ll ans = (1 + mod - modpow((mod - 1) * inv[3] % mod, x)) % mod * inv[2] % mod;
    
    out(ans);
    re0;
}
0