poj 3252 Round Numbers 数位DP
"Round Number "被称为其二进制形式中0的个数比1的个数多。求[x,y]区间内“Round Number”的个数。 解1: dp[pos][num],到当前数位pos,0的数量减去1的数量为num的方案数,一个简单的问题,中间某个pos位上num可能为负数(这不一定是非法的,因为我还没枚举完嘛,只要最终的num>=0才能判合法,中途某个pos就不一定了) Hash 最小就-32吧(好像),直接加上32,把32当0用。 这题主要是要想讲一下lead的用法,显然我要统计0的数量,前导零是有影响的。 #pragma comment(linker, "/STACK:10240000,10240000") #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<queue> #include<set> #include<vector> #include<map> #include<stack> #include<cmath> #include<algorithm> using namespace std; const double R=0.5772156649015328606065120900; const int N=1e5+5; const int mod=1e9+7;