//
// main.cpp
// HDU 3664 DP
//
// Created by 郑喆君 on 8/11/14.
// Copyright (c) 2014 itcast. All rights reserved.
//
#include<cstdio>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
typedef long long LL;
const int int_max = 0x07777777;
const int int_min = 0x80000000;
LL dp[1100][1100];
LL mod = 1000000007;
int n,k;
int main(int argc, const char * argv[])
{
memset(dp, 0, sizeof(dp));
for(int i = 1; i <= 1000; i++) {dp[i][0] = 1;}
for(int i = 2; i <= 1000; i++){
for(int j = 1; j < i; j++){
if(j >= i) break;
dp[i][j] = (dp[i-1][j]+dp[i-1][j-1]*(i-j)+dp[i-1][j]*j)%mod;
}
}
while (scanf("%d %d", &n, &k)!=EOF) {
cout << dp[n][k] << endl;
}
}
HDU 3664 DP
最新推荐文章于 2019-07-22 09:55:53 发布