結果

問題 No.1102 Remnants
ユーザー 夜
提出日時 2021-03-19 20:13:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 873 ms
コンパイル使用メモリ 91,980 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 14:49:26
合計ジャッジ時間 4,443 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 141 ms
5,376 KB
testcase_06 AC 30 ms
5,376 KB
testcase_07 AC 207 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 10 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 11 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 83 ms
5,376 KB
testcase_15 AC 66 ms
5,376 KB
testcase_16 AC 167 ms
5,376 KB
testcase_17 AC 157 ms
5,376 KB
testcase_18 AC 180 ms
5,376 KB
testcase_19 AC 62 ms
5,376 KB
testcase_20 AC 20 ms
5,376 KB
testcase_21 AC 108 ms
5,376 KB
testcase_22 AC 152 ms
5,376 KB
testcase_23 AC 117 ms
5,376 KB
testcase_24 AC 85 ms
5,376 KB
testcase_25 AC 182 ms
5,376 KB
testcase_26 AC 12 ms
5,376 KB
testcase_27 AC 48 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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