結果

問題 No.1102 Remnants
ユーザー 夜
提出日時 2021-03-19 20:13:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 91,112 KB
実行使用メモリ 4,880 KB
最終ジャッジ日時 2023-08-11 23:37:03
合計ジャッジ時間 5,482 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 137 ms
4,624 KB
testcase_06 AC 28 ms
4,380 KB
testcase_07 AC 200 ms
4,880 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 7 ms
4,384 KB
testcase_12 AC 10 ms
4,384 KB
testcase_13 AC 10 ms
4,384 KB
testcase_14 AC 83 ms
4,384 KB
testcase_15 AC 63 ms
4,380 KB
testcase_16 AC 163 ms
4,760 KB
testcase_17 AC 154 ms
4,868 KB
testcase_18 AC 174 ms
4,680 KB
testcase_19 AC 60 ms
4,380 KB
testcase_20 AC 19 ms
4,380 KB
testcase_21 AC 104 ms
4,384 KB
testcase_22 AC 148 ms
4,476 KB
testcase_23 AC 114 ms
4,384 KB
testcase_24 AC 82 ms
4,384 KB
testcase_25 AC 176 ms
4,680 KB
testcase_26 AC 12 ms
4,380 KB
testcase_27 AC 47 ms
4,380 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