专栏文章

题解:CF1513C Add One

CF1513C题解参与者 1已保存评论 0

文章操作

快速查看文章及其快照的属性,并进行相关操作。

当前评论
0 条
当前快照
1 份
快照标识符
@mip3ru2n
此快照首次捕获于
2025/12/03 05:41
3 个月前
此快照最后确认于
2025/12/03 05:41
3 个月前
查看原文

Code:

CPP
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod = 1e9 + 7;
int dp[10][200005];

signed main() {
	ios :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	for (int j = 0; j <= 200000; j ++) {
		for (int i = 0; i <= 9; i ++) {
			if (i + j <= 9) dp[i][j] = 1;
			else dp[i][j] = (dp[1][i + j - 10] + dp[0][i + j - 10]) % mod;
		}
	}
	string n;
	int T, m;
	cin >> T;
	while (T --) {
		cin >> n >> m;
		int ans = 0;
		for (int i = 0; i < n.size(); i ++) ans = (ans + dp[n[i] - '0'][m]) % mod;
		printf("%d\n", ans);
	}
	return 0;
}

评论

0 条评论,欢迎与作者交流。

正在加载评论...