Skip to content

Instantly share code, notes, and snippets.

@gedorinku
Last active January 16, 2016 15:48
Show Gist options
  • Save gedorinku/ab3b611b0722ede3a095 to your computer and use it in GitHub Desktop.
Save gedorinku/ab3b611b0722ede3a095 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;
static const int MOD = 100000;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int w, h;
while (cin >> w >> h, w) {
int dp[105][105][2][2] = {0}, dx[] = {-1, 0}, dy[] = {0, -1};
dp[1][2][1][1] = 1;
dp[2][1][0][0] = 1;
for (int x = 1; x <= w; ++x) {
for (int y = 1; y <= h; ++y) {
for (int i = 0; i < 2; ++i) {
int tx = x + dx[i], ty = y + dy[i];
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 2; ++k) {
if (!(i == j || j == k)) continue;
dp[x][y][i][j] += dp[tx][ty][j][k];
dp[x][y][i][j] %= MOD;
}
}
}
}
}
int ans = 0;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
ans += dp[w][h][i][j];
ans %= MOD;
}
}
cout << ans << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment