Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gzshawnliang committed Aug 11, 2019
1 parent 6a1b811 commit 8ebedc0
Show file tree
Hide file tree
Showing 5 changed files with 8,656 additions and 1 deletion.
2 changes: 1 addition & 1 deletion myCpps/!-OJcreater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using namespace std;

//***************************************
const string CPPfile = "aWalkThroughTheForest_UVA10917"; //*
const string CPPfile = "chestOfDrawers_UVA11420"; //*
//***************************************

ifstream fin(CPPfile + ".cpp");
Expand Down
36 changes: 36 additions & 0 deletions myCpps/chestOfDrawers_UVA11420.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <bits/stdc++.h>

using namespace std;

ifstream fin("chestOfDrawers_UVA11420.in");
ofstream fout("chestOfDrawers_UVA11420.out");

using ll = long long;
const ll N = 65;

int main()
{
vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 2, vector<ll>(2, 0)));
dp[1][0][0] = 1;
dp[1][1][1] = 1;

for (ll i = 2; i <= N; ++i)
{
dp[i][0][0] = dp[i - 1][1][1] + dp[i - 1][0][0];
for (ll j = 1; j <= i; ++j)
{
dp[i][j][0] = dp[i - 1][j + 1][1] + dp[i - 1][j][0];
dp[i][j][1] = dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1];
}
}

while (true)
{
ll n = -1, s = -1; fin >> n >> s;
if (n + s < 0) break;

fout << dp[n][s][0] + dp[n][s][1] << '\n';
}

return 0;
}
Loading

0 comments on commit 8ebedc0

Please sign in to comment.