結果
| 問題 |
No.1518 Simple Combinatorics
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-11 14:06:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 480 bytes |
| コンパイル時間 | 2,312 ms |
| コンパイル使用メモリ | 60,288 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-11 14:06:56 |
| 合計ジャッジ時間 | 2,548 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%d",&n,&k);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<iostream>
#define rep(i,n) for(i=0;i<(int)(n);i++)
#define MOD ((int)(1e9)+7)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n,k;
int power(int x,int a){
if(a==0)return 1;
int res=power((((long long)x%MOD)*(x%MOD))%MOD,a/2);
if(a%2==1)res=((long long)res*(x%MOD))%MOD;
return res;
}
int main(){
scanf("%d%d",&n,&k);
printf("%d\n",(int)((MOD+((ll)power(n,k)*n)%MOD-((ll)n*power(n-1,k))%MOD)%MOD));
return 0;
}