結果
問題 |
No.1518 Simple Combinatorics
|
ユーザー |
|
提出日時 | 2021-05-28 20:42:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 623 bytes |
コンパイル時間 | 1,096 ms |
コンパイル使用メモリ | 91,236 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 08:17:47 |
合計ジャッジ時間 | 1,734 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#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; cout << (m_pow(n, k + 1) - (n * m_pow(n - 1, k) % mod) + mod) % mod << endl; }