結果

問題 No.1102 Remnants
ユーザー 夜
提出日時 2021-03-19 20:13:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 93,748 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 19:14:41
合計ジャッジ時間 3,781 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long c[200020];
long long mod = 1000000007;
long long m_pow(long long x, long long y) {
	long long ans = 1;
	while (y > 0) {
		if ((y & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return ans;
}
int main() {
	long long n, k;
	cin >> n >> k;
	c[0] = 1;
	for (long long i = 1; i < n; i++) {
		c[i] = c[i - 1] * (k + i);
		c[i] %= mod;
		c[i] *= m_pow(i, 1000000005);
		c[i] %= mod;
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		a *= c[i];
		a %= mod;
		a *= c[n - i - 1];
		a %= mod;
		ans += a;
		ans %= mod;
	}
	cout << ans << endl;
}
0