結果

問題 No.1102 Remnants
ユーザー motmot
提出日時 2020-07-03 22:03:13
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,266 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 83,960 KB
実行使用メモリ 786,196 KB
最終ジャッジ日時 2023-10-17 02:34:34
合計ジャッジ時間 19,102 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 TLE -
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<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll fact[100000005];
ll N, K;

ll getcomb(ll a, ll b){
  ll ue = fact[a];
  ll shita1=1, shita2=1, tmpshita1, tmpshita2;
  ll h = mod-2;
  ll two;
  while(h>0){
    tmpshita1 = fact[b];
    tmpshita2 = fact[a-b];
    two = 1;
    while(2*two<=h){
      two *= 2;
      tmpshita1 *= tmpshita1;
      tmpshita1 %= mod;
      tmpshita2 *= tmpshita2;
      tmpshita2 %= mod;
    }
    h -= two;
    shita1 *= tmpshita1;
    shita2 *= tmpshita2;
    shita1 %= mod;
    shita2 %= mod;
  }
  return ue*shita1%mod*shita2%mod;
}

int main() {
  fact[0] = 1;
  for(ll i=1;i<100000005;++i){
    fact[i] = fact[i-1]*i%mod;
  }
  cin>>N>>K;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans = 0;
  for(int i=0;i<N;++i){
    ans += A[i]*getcomb(K+i, i)%mod*getcomb(K+N-i-1, N-i-1)%mod;
    ans %= mod;
  }
  cout<<ans<<endl;
}

0