結果
| 問題 |
No.1181 Product Sum for All Subsets
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-17 21:40:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 1,024 ms |
| コンパイル使用メモリ | 92,408 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 04:06:04 |
| 合計ジャッジ時間 | 2,148 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long mod = 1000000007;
long long m_pow(long long x, long long y) {
long long ans = 1;
while (y > 0) {
if ((y & 1) == 1) {
ans = ans * x % mod;
}
x = x * x % mod;
y >>= 1;
}
return ans;
}
int main() {
long long n, k;
cin >> n >> k;
k %= mod;
long long x = k * (k + 1) / 2 % mod;
long long x1 = (x + k) % mod;
long long ans = m_pow(x1, n) - m_pow(x, n);
cout << (ans + mod) % mod << endl;
}