結果

問題 No.1102 Remnants
ユーザー SSRSSSRS
提出日時 2020-07-03 22:38:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 169,448 KB
実行使用メモリ 9,012 KB
最終ジャッジ日時 2023-10-17 05:39:09
合計ジャッジ時間 5,493 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 TLE -
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;
long long MOD = 1000000007;
long long modpow(long long a, long long b){
	a %= MOD;
	long long res = 1;
	while (b > 0){
		if (b % 2 == 1) res = res * a % MOD;
		a = a * a % MOD;
		b = b / 2;
	}
	return res;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
long long modbinom2(long long n, long long r){
	long long res = 1;
	for (int i = 0; i < r; i++){
		res = res * (n - i) % MOD;
		res = res * modinv(i + 1) % MOD;
	}
	return res;
}int main(){
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  long long ans = 0;
  for (int i = 0; i < N; i++){
    long long tmp = A[i];
    tmp *= modbinom2(K + i, i);
    tmp %= MOD;
    tmp *= modbinom2(K + N - i - 1, N - i - 1);
    tmp %= MOD;
    ans += tmp;
  }
  cout << ans << endl;
}
0