結果

問題 No.1645 AB's abs
ユーザー ytsmash
提出日時 2021-08-14 13:55:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 806 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 194,668 KB
最終ジャッジ日時 2025-01-23 21:54:05
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 5 WA * 26 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *    author:  ytsmash
 *    created: 14.08.2021 13:34:43
 **/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }
    int mod = 998244353;
    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        int B = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                B += A[i];
            } else {
                B -= A[i];
            }
        }
        ans += abs(B) % mod;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}
0