結果
問題 | No.1518 Simple Combinatorics |
ユーザー |
![]() |
提出日時 | 2021-05-24 00:24:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 351 bytes |
コンパイル時間 | 1,889 ms |
コンパイル使用メモリ | 192,396 KB |
最終ジャッジ日時 | 2025-01-21 17:55:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 1 WA * 18 |
ソースコード
#include<bits/stdc++.h>using namespace std;const int mod=1000000007;long long modpow(int a, int n) {int res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}int main(){int N,K,ans;cin>>N>>K;ans=(modpow(N,K)-modpow(N-1,K))*N%mod;if(ans<0)ans+=mod;cout<<ans<<endl;}