結果
| 問題 |
No.140 みんなで旅行
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-06-05 19:09:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 5,000 ms |
| コード長 | 951 bytes |
| コンパイル時間 | 1,040 ms |
| コンパイル使用メモリ | 65,372 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-10-08 16:06:33 |
| 合計ジャッジ時間 | 1,787 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)
typedef long long ll;
ll dp[556][556];
ll comb[556][556];
ll power[556][556];
int main(void) {
int i, j, n;
cin >> n;
dp[0][0] = 1;
REP (i,1,n) REP (j,1,i)
if (j > 0) dp[i][j] = (dp[i-1][j-1] + j * dp[i-1][j]) % MOD;
comb[0][0] = 1;
REP (i,1,n) rep (j,i+1)
comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
REP (i,1,n) {
power[i][0] = 1;
REP (j,1,n)
power[i][j] = power[i][j-1] * i * (i-1) % MOD;
}
int ans = 0;
REP (i,1,n) REP (j,1,i)
ans = (ans + comb[n][i] * dp[i][j] % MOD * power[j][n-i]) % MOD;
cout << ans << endl;
return 0;
}
h_noson