結果

問題 No.1681 +-*
ユーザー 👑 Nachia
提出日時 2021-09-17 21:24:56
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 3,908 ms
コンパイル使用メモリ 111,120 KB
最終ジャッジ日時 2025-01-24 14:31:57
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)

using m32 = atcoder::modint1000000007;

int main(){
  int N; cin >> N;
  vector<m32> A(N);
  rep(i,N){ int a; cin >> a; A[i] = a; }
  rep(i,N-1) A[i+1] *= A[i];
  m32 ans = 0;
  for(int i=0; i<N; i++){
    ans *= 3;
    ans += A[i] * 2;
  }
  ans += A.back();
  ans /= 3;
  cout << ans.val() << endl;
  return 0;
}




struct ios_do_not_sync {
    ios_do_not_sync() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0