結果

問題 No.1102 Remnants
ユーザー 👑 NachiaNachia
提出日時 2020-10-21 22:51:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,305 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 165,924 KB
実行使用メモリ 5,152 KB
最終ジャッジ日時 2023-09-28 14:29:47
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,868 KB
testcase_01 AC 3 ms
5,044 KB
testcase_02 AC 3 ms
4,916 KB
testcase_03 AC 3 ms
4,944 KB
testcase_04 AC 3 ms
4,876 KB
testcase_05 AC 63 ms
4,972 KB
testcase_06 AC 17 ms
4,856 KB
testcase_07 AC 107 ms
4,872 KB
testcase_08 AC 4 ms
4,992 KB
testcase_09 AC 7 ms
4,972 KB
testcase_10 AC 3 ms
4,872 KB
testcase_11 AC 6 ms
4,980 KB
testcase_12 AC 7 ms
4,876 KB
testcase_13 AC 7 ms
4,924 KB
testcase_14 AC 41 ms
4,868 KB
testcase_15 AC 32 ms
5,104 KB
testcase_16 AC 80 ms
4,924 KB
testcase_17 AC 75 ms
4,868 KB
testcase_18 AC 93 ms
4,912 KB
testcase_19 AC 34 ms
4,916 KB
testcase_20 AC 12 ms
5,116 KB
testcase_21 AC 59 ms
5,044 KB
testcase_22 AC 81 ms
5,020 KB
testcase_23 AC 62 ms
4,868 KB
testcase_24 AC 45 ms
4,944 KB
testcase_25 AC 96 ms
4,972 KB
testcase_26 AC 8 ms
4,856 KB
testcase_27 AC 27 ms
5,152 KB
権限があれば一括ダウンロードができます

ソースコード

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[200001];

int N;
int K;

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

	MLL1 ans = 0;

	rep(i, N) {
		MLL1 a; cin >> *a;
		ans += a * F[i] * F[N - 1 - i];
	}

	cout << *ans << endl;

	return 0;
}
0