結果

問題 No.1681 +-*
ユーザー Nzt3Nzt3
提出日時 2022-09-29 22:07:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 2,379 ms
コンパイル使用メモリ 201,656 KB
実行使用メモリ 6,376 KB
最終ジャッジ日時 2023-08-24 05:08:43
合計ジャッジ時間 4,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 20 ms
6,376 KB
testcase_06 AC 20 ms
6,168 KB
testcase_07 AC 20 ms
6,136 KB
testcase_08 AC 28 ms
6,168 KB
testcase_09 AC 28 ms
6,236 KB
testcase_10 AC 29 ms
6,192 KB
testcase_11 AC 29 ms
6,144 KB
testcase_12 AC 29 ms
6,220 KB
testcase_13 AC 16 ms
4,524 KB
testcase_14 AC 29 ms
6,136 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 29 ms
6,140 KB
testcase_18 AC 29 ms
6,216 KB
testcase_19 AC 28 ms
6,164 KB
権限があれば一括ダウンロードができます

ソースコード

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