結果
問題 | No.665 Bernoulli Bernoulli |
ユーザー | kotatsugame |
提出日時 | 2020-03-05 13:02:43 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 597 ms / 2,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 688 ms |
コンパイル使用メモリ | 66,896 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-04 03:54:09 |
合計ジャッジ時間 | 10,598 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 597 ms
4,380 KB |
testcase_03 | AC | 588 ms
4,376 KB |
testcase_04 | AC | 554 ms
4,380 KB |
testcase_05 | AC | 515 ms
4,376 KB |
testcase_06 | AC | 509 ms
4,376 KB |
testcase_07 | AC | 493 ms
4,376 KB |
testcase_08 | AC | 495 ms
4,380 KB |
testcase_09 | AC | 559 ms
4,376 KB |
testcase_10 | AC | 494 ms
4,376 KB |
testcase_11 | AC | 579 ms
4,380 KB |
testcase_12 | AC | 558 ms
4,380 KB |
testcase_13 | AC | 580 ms
4,380 KB |
testcase_14 | AC | 583 ms
4,380 KB |
testcase_15 | AC | 508 ms
4,376 KB |
testcase_16 | AC | 528 ms
4,376 KB |
testcase_17 | AC | 514 ms
4,376 KB |
testcase_18 | AC | 494 ms
4,380 KB |
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; const long mod=1e9+7; long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;} long inv[10101]; long N,K; long S[10101]; main() { inv[1]=1; for(int i=2;i<10101;i++)inv[i]=(mod-mod/i)*inv[mod%i]%mod; cin>>N>>K; S[0]=N%mod; for(int i=1;i<=K;i++) { long now=power((N+1)%mod,i+1)+mod-1; long Ci=1; for(int j=0;j<i;j++) { now=(now+mod-Ci*S[j]%mod)%mod; Ci=Ci*(i+1-j)%mod*inv[j+1]%mod; } now=now*inv[i+1]%mod; S[i]=now; } cout<<S[K]<<endl; }