結果
問題 | No.665 Bernoulli Bernoulli |
ユーザー | kotatsugame |
提出日時 | 2020-03-05 13:02:28 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 513 bytes |
コンパイル時間 | 608 ms |
コンパイル使用メモリ | 67,028 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-22 02:18:44 |
合計ジャッジ時間 | 38,451 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; 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; }