摘要:
可以用f[i][j]表示递推到前i位时最后一段的和是j的情况种数,然后进行dp即可。#include<stdio.h>#include<string.h>#define MAXD 30#define MAXS 250int N, S, A[MAXD], f[MAXD][MAXS];char b[MAXD];void init(){ int i; N = strlen(b + 1); S = N * 9; A[0] = 0; for(i = 1; i <= N; i ++) A[i] = A[i - 1] + b[i] - '0';}void sol 阅读全文