結果

問題 No.1336 Union on Blackboard
ユーザー polyesterpolyester
提出日時 2021-01-15 23:23:54
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 140,964 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-26 18:29:56
合計ジャッジ時間 2,215 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main() {
  int t;
  cin >> t;
  while(t--) {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    for(int i = n - 1; i > 0; i--) {
      ll tmp = a[i] + a[i - 1] + (a[i] * a[i - 1]);
      a.pop_back();
      a.pop_back();
      tmp %= MOD;
      a.push_back(tmp);
    }
    cout << a[0] << '\n';
  }
  return 0;
}
0