結果
問題 | No.665 Bernoulli Bernoulli |
ユーザー | kotatsugame |
提出日時 | 2020-03-05 13:00:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 600 bytes |
コンパイル時間 | 627 ms |
コンパイル使用メモリ | 67,176 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-22 02:17:31 |
合計ジャッジ時間 | 39,315 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 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:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | 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 F[10101],I[10101]; long C(int N,int K){return F[N]*I[K]%mod*I[N-K]%mod;} long N,K; long S[10101]; main() { F[0]=1; for(int i=1;i<10101;i++)F[i]=F[i-1]*i%mod; I[10100]=power(F[10100],mod-2); for(int i=10100;i--;)I[i]=I[i+1]*(i+1)%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; for(int j=0;j<i;j++) { now=(now+mod-C(i+1,j)*S[j]%mod)%mod; } now=now*power(i+1,mod-2)%mod; S[i]=now; } cout<<S[K]<<endl; }