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