結果
| 問題 |
No.1518 Simple Combinatorics
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-19 22:17:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 482 bytes |
| コンパイル時間 | 1,558 ms |
| コンパイル使用メモリ | 166,848 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 00:04:44 |
| 合計ジャッジ時間 | 2,583 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
const int mod = 1000000007 ;
ll n , k ;
ll powmod(ll x , ll n){
ll res = 1 ;
while(n > 0){
if(n & 1) (res *= x) %= mod ;
(x *= x) %= mod ;
n >>= 1 ;
}
return res ;
}
int main(){
cin >> n >> k ;
cout << (powmod(n,k) - powmod(n-1,k) + mod) % mod * n % mod << endl ;
}