ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213421 | #2355. Digit | KXG | 80 | 5697ms | 1276kb | C++11 | 893b | 2024-11-11 21:52:25 | 2024-11-11 23:09:03 |
answer
#include <cstdio>
#include <algorithm>
using namespace std;
int n, ans;
int pw10[610];
int dp[2][100010];
int main() {
scanf("%d", &n);
for (int i = 0; i <= 500; i++) {
if (i == 0) pw10[i] = 1;
else pw10[i] = pw10[i - 1] * 10 % n;
}
int flag = 0;
for (int i = 0; i < n; i++) {
dp[0][i] = 1e9;
}
for (int i = 0; i <= 200; i++) {
flag ^= 1;
for (int j = 0; j < n; j++) {
dp[flag][j] = 1e9;
}
for (int j = 0; j <= 9; j++) {
for (int k = 0; k < n; k++) {
dp[flag][k] = min(dp[flag][k], dp[flag ^ 1][(k - j * pw10[i] % n + n) % n] + j * j);
}
if (j != 0) {
dp[flag][j * pw10[i] % n] = min(dp[flag][j * pw10[i] % n], j * j);
}
}
}
printf("%d\n", dp[flag][0]);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 704ms
memory: 1152kb
input:
81920
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Wrong Answer
time: 483ms
memory: 948kb
input:
55966
output:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'
Test #3:
score: 0
Wrong Answer
time: 851ms
memory: 1240kb
input:
92661
output:
6
result:
wrong answer 1st numbers differ - expected: '3', found: '6'
Test #4:
score: 10
Accepted
time: 586ms
memory: 1044kb
input:
68013
output:
18
result:
ok 1 number(s): "18"
Test #5:
score: 10
Accepted
time: 633ms
memory: 1084kb
input:
72927
output:
27
result:
ok 1 number(s): "27"
Test #6:
score: 10
Accepted
time: 129ms
memory: 628kb
input:
15047
output:
5
result:
ok 1 number(s): "5"
Test #7:
score: 10
Accepted
time: 517ms
memory: 980kb
input:
59994
output:
36
result:
ok 1 number(s): "36"
Test #8:
score: 10
Accepted
time: 854ms
memory: 1276kb
input:
97273
output:
10
result:
ok 1 number(s): "10"
Test #9:
score: 10
Accepted
time: 458ms
memory: 908kb
input:
51139
output:
14
result:
ok 1 number(s): "14"
Test #10:
score: 10
Accepted
time: 482ms
memory: 948kb
input:
55788
output:
15
result:
ok 1 number(s): "15"