QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#354463 | #7996. 报数 IV | PorNPtree# | WA | 25ms | 74496kb | C++14 | 1.3kb | 2024-03-15 14:03:43 | 2024-03-15 14:03:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int calc(int x, int y)
{
if (!y) {
return x;
}
if (y > 10) {
return (x % 9 == 0 ? 9 : x % 9);
}
int A = 0;
while (x) {
A += x % 10;
x = x / 10;
}
return calc(A, y - 1);
}
const int P = 1e9 + 7;
int f[1005][2][9005];
signed main()
{
int T;
scanf("%d", &T);
while (T--) {
string n;
cin >> n;
n = ' ' + n;
memset(f, 0, sizeof(f));
f[0][1][0] = 1;
for (int i = 1; i < (int)n.size(); ++i) {
for (int j = 0; j <= i * 9; ++j) {
f[i][1][j] = f[i - 1][1][j - (n[i] - '0')];
for (int k = 0; k <= 9 && k <= j; ++k) {
f[i][0][j] = (f[i][0][j] + f[i - 1][0][j - k]) % P;
if (k < n[i] - '0') {
f[i][0][j] = (f[i][0][j] + f[i - 1][1][j - k]) % P;
}
}
}
}
int k, m, A = 0;
scanf("%d%d", &k, &m);
for (int i = 1; i <= (int)(n.size() - 1) * 9; ++i) {
if (calc(i, k - 1) == m) {
A = (0ll + A + f[(int)n.size() - 1][0][i] + f[(int)n.size()][1][i]) % P;
}
}
printf("%d\n", A);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 74496kb
input:
2 114 1 5 514 2 10
output:
8 10
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 25ms
memory: 74484kb
input:
5 114 1 5 514 2 10 114514 3 7 1919810 2 13 1145141919810114514191981011451419198101145141919810114514191981011451419198101145141919810114514191981011451419198101145141919810 1 79
output:
8 10 12723 504 481046284
result:
wrong answer 3rd lines differ - expected: '12724', found: '12723'