Download presentation
Presentation is loading. Please wait.
Published byAugust Jenssen Modified over 5 years ago
4
int DP_ABString(int count)
{ int fa[1000], fb[1000]; if(count > 1000) return -1; memset(fa, 0, sizeof(fa)); memset(fb, 0, sizeof(fb)); for(int i = 1; i < count; i++) fa[i] = fa[i-1] + fb[i-1]; fb[i] = fb[i-1] + fa[i-1] + i%2; } return fb[count-1];
10
int DP_Domino(int n) { int d[1000][3]; if(n%2) return -1; d[1][0] = d[1][2] = 1; d[0][0] = d[1][1] = d[0][2] = 1; for(int i = 2; i <= n; i++) d[i][0] = d[i-2][0] + d[i-1][1] + d[i-2][2]; d[i][1] = d[i-1][2]; d[i][2] = d[i][0] + d[i-1][1]; } return d[n][0];
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.