結果

問題 No.140 みんなで旅行
ユーザー 👑 kmjpkmjp
提出日時 2014-12-22 00:59:38
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 985 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 144,848 KB
実行使用メモリ 26,612 KB
最終ジャッジ日時 2023-09-02 21:18:35
合計ジャッジ時間 2,932 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
26,396 KB
testcase_01 AC 26 ms
26,468 KB
testcase_02 WA -
testcase_03 AC 26 ms
26,276 KB
testcase_04 AC 26 ms
26,380 KB
testcase_05 AC 27 ms
26,336 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll mo=1000000007;
ll C[1005][1005], P[1005][1005], Q[1005][1005];

int main(int argc,char** argv){
	int x,y,z;
	
	cin>>N;
	for(x = 0; x < 1002; x++) {
		C[x][0]=1;
		for(y = 1; y <= x; y++) C[x][y] = (C[x-1][y] + C[x-1][y-1]) % mo;
	}
	
	for(x = 1; x < 1002; x++) {
		P[x][1]=1;
		for(y = 2; y <= x; y++) P[x][y] = (P[x-1][y-1] + y * P[x-1][y]) % mo;
	}
	for(y = 0; y < 1002; y++) {
		Q[y][0] = 1;
		for(z = 0; z <= y; z++) Q[y][z+1] = Q[y][z] * y * (y-1) % mo;
	}
	
	ll ret = 0;
	for(x = 1; x <= N; x++)
		for(y = 1; y <= x; y++) {
			ret = (ret + C[N][x] * P[x][y] % mo * Q[y][N-x]) % mo;
		}
	
	cout << ret << endl;
}
0