标签:lang lin lan type space abc strlen mat 代码
否则直接
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll N = 1e6 + 9, mod = 1e9 + 7;
int n;
char s[N];
ll dp[15][N];
ll q_mi(ll a, ll k, ll p) {
ll ret = 1;
ll x = a;
while (k) {
if (k & 1) {
(ret *= x )%= p;
}
(x *= x)%=p;
k >>= 1;
}
return ret;
}
int main() {
cin >> (s + 1);
int n = strlen(s + 1);
dp[0][0] = 1;
for (int i = 1; i <= n; i ++) {
if (s[i] == ‘?‘) {
for (int k = 0; k <= 9; k ++)
for (int j = 0; j <= 12; j ++) {
(dp[(j * 10 + k)%13][i] += dp[j][i-1]) %= mod;
}
} else {
for (int j = 0; j <= 12; j++) {
(dp[(j * 10 + s[i] - ‘0‘) % 13][i] += dp[j][i - 1]) %= mod;
}
}
//cout << dp[5][i] << endl;
}
cout << dp[5][n] << endl;
}
标签:lang lin lan type space abc strlen mat 代码
原文地址:https://www.cnblogs.com/Xiao-yan/p/14664097.html