超级难想的一道题
用一棵十叉数来统计
因为是各个数位之和 所以要把之前各个数位的和sum记录下来
因为每个数位(子树)并不一定完整的分成cnt组 最后可能有剩余 所以每一个数位(子树)前面肯能会有多余的空间 用rem记录
因为需要每组末的空间是在统计时不断改变的 所以dp时要同时记录组数和最后的空余
实现方面 沿用上一个记忆化搜索的思路 传入两个参数unlimit1 unlimit2 表示该位置上的数的取值是否受到读入的L 和 R 的限制 只有不受限制时找到的DP值才能作为d数组中的元素记录下来
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int MAXN = 18;
const int MAXK = 1000;
struct node{
LL cnt, res;
node(){}
node(LL x, LL y) { cnt = x; res = y; }
node operator += (node t)
{
cnt +