結果
問題 |
No.1181 Product Sum for All Subsets
|
ユーザー |
![]() |
提出日時 | 2020-07-24 11:26:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 1,682 ms |
コンパイル使用メモリ | 166,540 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 22:37:07 |
合計ジャッジ時間 | 2,248 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#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)/2)%mod); ull k=((a*(a+1)/2)%mod); ull ans=modpow(s,b,mod)%mod-modpow(k,b,mod)%mod; if(ans<0){ ans=ans+1000000007; } cout<<ans<<endl; }