結果
| 問題 |
No.1681 +-*
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-18 18:01:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 692 bytes |
| コンパイル時間 | 1,527 ms |
| コンパイル使用メモリ | 169,096 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-30 15:40:04 |
| 合計ジャッジ時間 | 3,486 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll modpow(ll x,ll n,ll mod){
ll res=1;
while(n>0){
if(n&1){
res=res*x%mod;
}
x=x*x%mod;
n>>=1;
}
return res%mod;
}
int main(){
int N;
cin>>N;
vector<ll> A(N);
for(int i=0;i<N;i++){
cin>>A[i];
}
ll mod=1e9+7;
ll ans=0;
ll temp=1;
for(int i=0;i<N;i++){
ll x=temp*A[i];
x%=mod;
x*=modpow(3,N-i-2,mod);
x%=mod;
if(i<N-1) x*=2;
x%=mod;
ans+=x;
ans%=mod;
temp*=A[i];
temp%=mod;
}
ans=(10*mod+ans)%mod;
cout<<ans<<endl;
return 0;
}