結果
問題 | No.1181 Product Sum for All Subsets |
ユーザー |
![]() |
提出日時 | 2020-07-24 11:22:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 590 bytes |
コンパイル時間 | 1,723 ms |
コンパイル使用メモリ | 166,968 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 22:36:59 |
合計ジャッジ時間 | 2,270 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 1 WA * 26 |
ソースコード
#include <bits/stdc++.h>#include <iostream>#include <random>using namespace std;using ull = long long;ull modmul(ull x, ull y, ull mod){ull ret = 0;while(y){if(y & 1){ret = (ret + x) % mod;}x = x * 2 % mod;y >>= 1;}return ret;}ull modpow(ull x, ull n, ull mod){ull ret = 1;while(n){if(n & 1){ret = modmul(ret, x, mod);}x = modmul(x, x, mod);n >>= 1;}return ret;}int main(){ull a,b;cin>>b>>a;ull mod=1000000007;a=a%mod;ull s=(a*(a+3)%mod);ull k=(a*(a+1)%mod);cout<<modpow(s,b,mod)%mod-modpow(k,b,mod)%mod<<endl;}