FZU2109 数位dp 含前导零
这题没考虑到前导0,就是不知道哪wa了,又补题一直wa,scanf和printf改成cin cout就对了 真不知道错在哪了。。。刚刚又试了一下,G++scanf过不了 但是visual C++可以。真服了,浪费我又一个多小时。 这道题是简单的数位dp!!!注意前导0!前导0!前导0!掉坑的地方说三遍,顺便庆祝下因为前导0,成功爆0。 思路:就是数位dp模板题,不过置前导0的时候要注意技巧,就是num要放9。为什么放9呢?因为放9不会限制后面取数。暂且这么记吧,我真没整明白为啥放9呜呜呜。 下面是AC代码!一定要掌握前导0的处理! # include <cstdio> # include <iostream> # include <cstring> # include <cmath> # include <algorithm> # define ll long long # define maxn 20 using namespace std ; //这题注意前导0!!! int dig [ maxn ] ; ll dp [ maxn ] [ maxn ] [ 2 ] ; ll dfs ( int pos , int num , int odd , int pre0 , int limit ) { if ( ! pos ) return 1 ; if ( ! limit && dp