結果
問題 |
No.1102 Remnants
|
ユーザー |
![]() |
提出日時 | 2020-07-04 01:17:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 805 ms |
コンパイル使用メモリ | 93,080 KB |
最終ジャッジ日時 | 2025-01-11 15:18:25 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; constexpr int P = 1000000007; ll powmod(ll n, ll k) { ll r = 1, t = n % P; for (; k != 0; k /= 2) { if (k & 1) r = r * t % P; t = t * t % P; } return r; } ll modinv(ll n) { return powmod(n, P - 2); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> x(n); x[0] = 1; for (int i = 1; i < n; i++) { x[i] = (ll)x[i - 1] * modinv(i) % P * (k + i) % P; } ll r = 0; for (int i = 0; i < n; i++) { int a; cin >> a; r += (ll)a * x[i] % P * x[n - 1 - i] % P; } r %= P; cout << r << endl; return 0; }