結果

問題 No.1181 Product Sum for All Subsets
ユーザー RhoRho
提出日時 2020-08-21 21:42:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 164,516 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 05:42:00
合計ジャッジ時間 3,242 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
6,812 KB
testcase_01 AC 28 ms
6,812 KB
testcase_02 AC 29 ms
6,940 KB
testcase_03 AC 27 ms
6,940 KB
testcase_04 AC 26 ms
6,940 KB
testcase_05 AC 28 ms
6,944 KB
testcase_06 AC 27 ms
6,940 KB
testcase_07 AC 28 ms
6,940 KB
testcase_08 AC 27 ms
6,940 KB
testcase_09 AC 27 ms
6,940 KB
testcase_10 AC 27 ms
6,940 KB
testcase_11 AC 29 ms
6,940 KB
testcase_12 AC 53 ms
6,944 KB
testcase_13 AC 31 ms
6,940 KB
testcase_14 AC 49 ms
6,940 KB
testcase_15 AC 45 ms
6,940 KB
testcase_16 AC 52 ms
6,940 KB
testcase_17 AC 37 ms
6,940 KB
testcase_18 AC 50 ms
6,944 KB
testcase_19 AC 48 ms
6,940 KB
testcase_20 AC 53 ms
6,944 KB
testcase_21 AC 43 ms
6,940 KB
testcase_22 AC 35 ms
6,944 KB
testcase_23 AC 31 ms
6,940 KB
testcase_24 AC 34 ms
6,940 KB
testcase_25 AC 39 ms
6,944 KB
testcase_26 AC 27 ms
6,940 KB
testcase_27 AC 27 ms
6,940 KB
testcase_28 AC 56 ms
6,940 KB
testcase_29 AC 56 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define vi vector<ll>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
ll kj[200006],kji[200006];
ll modpow(ll a,ll x){
  ll res=1;
  while(x){
    if(x&1)res=res*a%mod;
    a=a*a%mod;
    x>>=1;
  }
  return res;
}
void setkj(){
  ll maxA=200000;
  kj[0]=1;
  rep(i,maxA)kj[i+1]=kj[i]*(i+1)%mod;
  rep(i,maxA+1)kji[i]=modpow(kj[i],mod-2);
}
ll comb(ll r,ll c){
  return kj[r]*kji[c]%mod*kji[r-c]%mod;
}

signed main(){
  setkj();
  ll n,k;cin>>n>>k;
  k%=mod;
  ll m=k*(k+1)/2%mod;
  ll ans=0;
  rep(i,n){
    ans+=comb(n,i)*modpow(m,i)%mod*modpow(k,n-i);
    ans%=mod;
  }
  cout<<ans<<endl;
}
0