BZOJ 1026: [SCOI2009]windy数
2017-12-27 21:43
232 查看
二次联通门 : BZOJ 1026: [SCOI2009]windy数
/* 水题开心 */ #include <cstdio> #include <iostream> #include <cstring> #define rg register int f[20][20], c[20], cur; inline int abs (int x) { return x < 0 ? -x : x; } int dfs (int n, int l, bool led, bool lim) { if (n == 0) return 1; if (!lim && !led && f [l] >= 0) return f [l]; int up = lim ? c : 9, res = 0; for (int i = 0; i <= up; ++ i) { if (!led && abs (i - l) < 2 && n != cur) continue; if (led && i == 0) res += dfs (n - 1, i, true, lim && i == up); else res += dfs (n - 1, i, led && i == 0, lim && i == up); } return (!lim && !led) ? f [l] = res : res; } int sv (int key) { for (cur = 0; key; c[++ cur] = key % 10, key /= 10); return dfs (cur, 0, true, true); } int main (int argc, char *argv[]) { int A, B; scanf ("%d%d", &A, &B); memset (f, -1, sizeof f); printf ("%d", sv (B) - sv (A - 1)); return 0; }
相关文章推荐
- BZOJ 1026 [SCOI2009]windy数 数位dp
- bzoj1026 [SCOI2009]windy数
- bzoj1026 [SCOI2009]windy数
- bzoj1026 [SCOI2009]windy数
- BZOJ1026(SCOI2009)[windy数]--数位DP
- bzoj 1026: [SCOI2009]windy数 (数位dp)
- [BZOJ 1026] [SCOI 2009] Windy数 【数位DP】
- [BZOJ1026][SCOI2009]windy数
- BZOJ1026: [SCOI2009]windy数
- BZOJ1026: [SCOI2009]windy数[数位DP]
- [bzoj1026][SCOI2009]windy数
- BZOJ 1026: [SCOI2009]windy数 【数位dp】
- [BZOJ1026][SCOI2009]windy数(数位DP)
- bzoj 1026 [SCOI2009]windy数
- BZOJ 1026: [SCOI2009]windy数 (裸的数位dp)
- [BZOJ 1026] SCOI 2009 windy数 · 动态规划
- [BZOJ 1026][SCOI2009]windy数:DP
- 【BZOJ】【1026】【SCOI2009】Windy数
- 【BZOJ 1026】【SCOI 2009】windy数 【数位DP】
- 【BZOJ 1026】 [SCOI2009]windy数