結果

問題 No.1681 +-*
ユーザー Nzt3
提出日時 2022-09-29 22:07:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 195,108 KB
最終ジャッジ日時 2025-02-07 18:27:07
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<long long>A(N);
  for(auto &i:A)cin>>i;
  const int mod=1e9+7;
  vector<long long>b3(N);
  b3[0]=b3[1]=1;
  for(int i=2;i<N;i++){
    b3[i]=b3[i-1]*3%mod;
  }
  long long ans=0,t=1;
  for(int i=0;i<N;i++){
    t=t*A[i]%mod;
    ans=(ans+t*(i==N-1?1:2)*b3[N-1-i])%mod;
  }
  cout<<ans<<'\n';
}
0