結果
問題 | No.1518 Simple Combinatorics |
ユーザー |
|
提出日時 | 2023-07-18 14:47:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 654 bytes |
コンパイル時間 | 877 ms |
コンパイル使用メモリ | 96,524 KB |
最終ジャッジ日時 | 2025-02-15 15:34:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<ll,ll> P; typedef pair<int,P> PP; const ll MOD=1e9+7; ll mod_pow(ll x,ll y,ll mod){ ll res=1; while(y>0){ if(y&1){ res*=x; res%=mod; } x*=x; x%=mod; y/=2; } return res; } int main(){ ll N,K; cin>>N>>K; ll ans=(mod_pow(N,K,MOD) - mod_pow(N-1,K,MOD)+MOD)%MOD; ans*=N; ans%=MOD; cout<<ans<<endl; }