이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = 400;
const int MOD = (int)1e9 + 7;
int dp[N][N][2];
int C[N][N];
void add(int &a, int b){
a += b;
if(a >= MOD)
a -= MOD;
}
int mult(int a, int b){
return (a * 1ll * b) % MOD;
}
int main(){
fastIO;
int n;
cin >> n;
for(int i = 0; i < N ; i ++ )
C[i][0]=1;
for(int i = 1; i < N; i ++ ){
for(int j = 1; j <= i; j ++ ){
add(C[i][j], C[i-1][j]);
add(C[i][j], C[i-1][j-1]);
}
}
dp[0][0][0]=1;
for(int i = 0; i < n; i ++ ){
for(int j = 0 ; j <= n; j ++ ){
for(int bit = 0; bit < 2; bit ++ ){
for(int x = 0; j + x <= n; x ++ ){
add(dp[i + 1][j + x][(bit | (x == (i + 1)))],
mult(dp[i][j][bit],C[n-j][x])
);
}
}
}
}
cout << dp[n][n][1] << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |