結果

問題 No.1681 +-*
ユーザー monnumonnu
提出日時 2021-09-18 10:47:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 3,833 ms
コンパイル使用メモリ 227,732 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2023-09-12 20:27:17
合計ジャッジ時間 6,524 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 44 ms
6,976 KB
testcase_06 AC 44 ms
7,108 KB
testcase_07 AC 44 ms
6,976 KB
testcase_08 AC 79 ms
6,984 KB
testcase_09 AC 79 ms
7,036 KB
testcase_10 AC 79 ms
7,108 KB
testcase_11 AC 80 ms
7,036 KB
testcase_12 AC 79 ms
7,168 KB
testcase_13 AC 40 ms
4,984 KB
testcase_14 AC 79 ms
7,096 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 78 ms
7,120 KB
testcase_18 AC 80 ms
7,324 KB
testcase_19 AC 78 ms
7,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 2000005
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000000
//#define INF 1000000000000000000

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<ll> pow2(N+1,1);
  vector<ll> pow3(N+1,1);
  for(int i=1;i<=N;i++){
    pow2[i]=2*pow2[i-1]%MOD;
    pow3[i]=3*pow3[i-1]%MOD;
  }
  ll ans=0;
  ll x=1;
  for(int i=0;i<N-1;i++){
    x=x*A[i]%MOD;
    ans+=x*2*pow3[N-2-i];
    ans%=MOD;
  }
  x=x*A[N-1]%MOD;
  ans+=x;
  ans%=MOD;
  cout<<ans<<'\n';

}
0