結果

問題 No.1102 Remnants
ユーザー 👑 NachiaNachia
提出日時 2020-10-21 22:42:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,365 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 166,452 KB
実行使用メモリ 813,984 KB
最終ジャッジ日時 2023-09-28 14:29:40
合計ジャッジ時間 6,236 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

template<ULL M>
struct MLL {
	ULL x;
	MLL(ULL val = 0) : x(val) {}

	MLL& operator+=(MLL r) { x += r.x; if (x >= M) x -= M; return *this; }
	MLL operator+(MLL r) const { MLL res = x; return res += r; }
	MLL& operator-=(MLL r) { x += M - r.x; if (x >= M) x -= M; return *this; }
	MLL operator-(MLL r) const { MLL res = x; return res -= r; }
	MLL& operator*=(MLL r) { x = x * r.x % M; return *this; }
	MLL operator*(MLL r) const { return MLL(x * r.x % M); }
	MLL operator^(ULL r) const {
		if (r == 0) return MLL(1);
		MLL res = (*this * *this) ^ (r / 2);
		if (r % 2) res *= *this;
		return res;
	}
	MLL& operator^=(ULL r) { return *this = *this ^ r; }
	MLL& operator/=(MLL r) { *this *= r ^ (M - 1); return *this; }
	MLL operator/(MLL r) const { return *this * (r ^ (M - 2)); }
	ULL& operator*() { return x; }
	const ULL& operator*() const { return x; }
};

using MLL1 = MLL<1000000007>;

MLL1 F[110000001];

MLL1 C(int n, int r) {
	return F[n] / F[r] / F[n - r];
}

int N;
int K;
ULL A[200000];

int main() {
	cin >> N >> K;
	F[0] = 1;
	rep(i, 110000000) F[i + 1] = F[i] * (i + 1);

	MLL1 ans = 0;

	rep(i, N) {
		MLL1 a; cin >> *a;
		ans += a * C(K + i, K) * C(K + N - 1 - i, K);
	}

	cout << *ans << endl;

	return 0;
}
0