P2602 [ZJOI2010]数字计数(递推+数位dp写法)
P2602 [ZJOI2010]数字计数
递推写法:
主要观察到对于所有小于1000的数每一个数字1,2,3,...都是平均出现的(不考虑前导零)
#include
using namespace std;
typedef long long ll;
const int maxn=1e6+100;
#define debug(x) cout<<#x<<':'<=0;i--){
for(int j=0;j<=9;j++) dp[j]+=i*(zahn[i]/10)*bits[i];//后面的位数是平均的
for(int j=0;j
数位dp写法:
1.要考虑前导零
2.要记得dp每次赋值为-1
#include
using namespace std;
typedef long long ll;
#define debug(x) cout<<#x<<':'<