結果
問題 | No.140 みんなで旅行 |
ユーザー | kotatsugame |
提出日時 | 2020-03-04 16:06:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,904 ms / 5,000 ms |
コード長 | 513 bytes |
コンパイル時間 | 553 ms |
コンパイル使用メモリ | 66,516 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-04-22 01:39:06 |
合計ジャッジ時間 | 15,661 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 35 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2,894 ms
5,376 KB |
testcase_12 | AC | 19 ms
5,376 KB |
testcase_13 | AC | 6 ms
5,376 KB |
testcase_14 | AC | 2,904 ms
5,376 KB |
testcase_15 | AC | 2,890 ms
5,376 KB |
testcase_16 | AC | 702 ms
5,376 KB |
testcase_17 | AC | 231 ms
5,376 KB |
testcase_18 | AC | 1,962 ms
5,376 KB |
testcase_19 | AC | 2,279 ms
5,376 KB |
testcase_20 | AC | 161 ms
5,376 KB |
testcase_21 | AC | 3 ms
5,376 KB |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; int N; long mod=1e9+7,dp[600]; long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;} main() { cin>>N; long ans=0,fac=1; for(int k=1;k<=N;k++) { for(int i=0;i<=k;i++)dp[i]=0; dp[0]=1; for(int i=0;i<N;i++) { for(int j=i;j>=0;j--) { long now=dp[j]; dp[j]=0; (dp[j]+=now*k*(k-1))%=mod; (dp[j]+=now*j)%=mod; (dp[j+1]+=now*(k-j))%=mod; } } fac=fac*k%mod; (ans+=dp[k]*power(fac,mod-2))%=mod; } cout<<ans<<endl; }