結果

問題 No.140 みんなで旅行
ユーザー kotatsugamekotatsugame
提出日時 2020-03-04 16:12:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,827 ms / 5,000 ms
コード長 473 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 65,336 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-22 01:40:14
合計ジャッジ時間 20,105 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 44 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 3,781 ms
8,576 KB
testcase_12 AC 24 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 3,827 ms
8,576 KB
testcase_15 AC 3,766 ms
8,576 KB
testcase_16 AC 914 ms
6,400 KB
testcase_17 AC 303 ms
5,376 KB
testcase_18 AC 2,588 ms
8,064 KB
testcase_19 AC 2,955 ms
8,192 KB
testcase_20 AC 209 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
long mod=1e9+7,dp[600][1200];
main()
{
	cin>>N;
	dp[0][0]=1;
	for(int k=0;k<N;k++)
	{
		for(int i=k;i>=0;i--)for(int j=2*k-i;j>=0;j--)
		{
			long now=dp[i][j];
			dp[i][j]=0;
			(dp[i][j+2]+=now)%=mod;
			(dp[i][j+1]+=now*(i+j)*2)%=mod;
			(dp[i][j]+=now*((i+j)*(i+j)-j))%=mod;
			if(j>=1)(dp[i+1][j-1]+=now*j)%=mod;
			(dp[i+1][j]+=now)%=mod;
		}
	}
	long ans=0;
	for(int i=1;i<=N;i++)ans+=dp[i][0];
	cout<<ans%mod<<endl;
}
0