QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#72788 | #5006. Heximal | 2141302067 | TL | 2ms | 5684kb | C++14 | 1.6kb | 2023-01-19 11:46:11 | 2023-01-19 11:46:15 |
Judging History
answer
#include<stdio.h>
#include<string.h>
int a[5000050], b[5000050],g[10],f[100],h[100];
char s[5000050];
int main() {
scanf("%s", s);
int m = strlen(s);
for (int i = 1; i <= m; i++) {
a[i] = (s[i - 1] - '0');
}
for (int i = 0; i <= 9; i++) {
g[i] = i * 6;
}
for (int i = 0; i <= 99; i++) {
f[i] = i % 10;
h[i] = i / 10;
}
if (m == 1) {
if (a[m] < 6)
printf("1");
else printf("2");
return 0;
}
int n = m;
b[m] = 1;
long long t = 0;
while (++t) {
for (int i = m; i <= n; i++) {
b[i] = g[b[i]];
}
for (int i = n; i >= m; i--) {
int c = b[i];
b[i] = f[c];
b[i - 1] += h[c];
}
if (b[m-1]!=0) {
--m;
if (m == 1) {
int d = 0;
for (int i = 1; i <= n; i++) {
if (b[i] > a[i]) {
d = 2;
break;
}
else if (b[i] < a[i]) {
d = 1;
break;
}
}
if (d == 0) {
t++;
break;
}
else if (d == 2) {
break;
}
else {
t++;
for (int i = m; i <= n; i++) {
b[i] = g[b[i]];
}
for (int i = n; i >= m; i--) {
int c = b[i];
b[i] = f[c];
b[i - 1] += h[c];
}
if (b[m - 1] != 0) {
--m;
}
if (m == 0) {
break;
}
int d = 0;
for (int i = 1; i <= n; i++) {
if (b[i] > a[i]) {
d = 2;
break;
}
else if (b[i] < a[i]) {
d = 1;
break;
}
}
if (d == 0 || d == 1) {
t++;
break;
}
else if (d == 2) {
break;
}
}
}
}
}
printf("%lld", t);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5560kb
input:
0
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 2ms
memory: 5516kb
input:
1865
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5584kb
input:
6
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 0ms
memory: 5624kb
input:
5
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 2ms
memory: 5684kb
input:
216
output:
4
result:
ok single line: '4'
Test #6:
score: -100
Time Limit Exceeded
input:
659048550435237232393875796171343597297252783860791224966151609834498375660891507785647188078990198766575546966667938541517709208360385263203130845215396367798902376853652489767206051858708602045962531467486884777174160264291462611744982439094276291073422016146183934443085743192727084631329374278797...