結果

問題 No.1181 Product Sum for All Subsets
ユーザー pockyny
提出日時 2020-08-21 21:45:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 415 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 66,048 KB
最終ジャッジ日時 2025-01-13 05:34:31
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll pw(ll a,ll x){
    ll ret = 1;
    a %= mod;
    while(x){
        if(x&1) (ret *= a) %= mod;
        x /= 2; (a *= a) %= mod;
    }
    return ret;
}

int main(){
    ll n,k,inv = (mod + 1)/2; cin >> n >> k;
    ll ans = (pw((k + 3)%mod*k%mod*inv%mod,n) - pw((k + 1)%mod*k%mod*inv%mod,n) + mod)%mod;
    cout << ans << endl;
}
0