結果
| 問題 |
No.1681 +-*
|
| コンテスト | |
| ユーザー |
たまごん
|
| 提出日時 | 2021-09-17 23:16:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 557 bytes |
| コンパイル時間 | 1,384 ms |
| コンパイル使用メモリ | 167,572 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-29 22:02:52 |
| 合計ジャッジ時間 | 3,270 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const long long INF = 1LL << 60;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
int main() {
ll n, num = 2, ans = 0, anss;
cin >> n >> anss;
rep(i,n-2) num = num*3%MOD;
anss %= MOD;
ans += anss*num%MOD;
rep(i,n-1){
num = (num+num%3*MOD)/3;
if(i == n-2) num = 1;
ll a;
cin >> a;
anss = anss*a%MOD;
ans = (ans+anss*num)%MOD;
}
cout << ans << endl;
}
たまごん