結果

問題 No.1336 Union on Blackboard
ユーザー sten_san
提出日時 2021-01-15 23:24:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 1,902 ms
コンパイル使用メモリ 191,340 KB
最終ジャッジ日時 2025-01-17 20:40:04
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> using lqueue = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using gqueue = priority_queue<T, vector<T>, less<T>>;

int main() {
    constexpr int64_t mod = 1e9 + 7;

    auto op = [&](int64_t a, int64_t b) {
        return (a + b + a * b) % mod;
    };

    int t; cin >> t;
    while (t--) {
        int n; cin >> n;

        int64_t ans = 0;
        for (int i = 0; i < n; ++i) {
            int a; cin >> a;
            ans = op(ans, a);
        }

        cout << ans << endl;
    }
}

0