Submission #860151

# Submission time Handle Problem Language Result Execution time Memory
860151 2023-10-11T19:51:17 Z raphaelp Palindrome-Free Numbers (BOI13_numbers) C++14
73.75 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
long long nb(long long N)
{
    if (N == -1)
        return 0;
    long long mult = 1;
    int var = 0;
    while (pow(10, var) < N)
        var++;
    long long tot = 0;
    int first = 0;
    long long i = 1;
    for (int j = 0; i < N; j++)
    {
        i = pow(10, j);
        if (N / i > 9 && (N / i) % 10 == (N / i / 10) % 10)
        {
            first = j + 1;
        }
        if (N / i > 99 && (N / i) % 10 == (N / i / 100) % 10)
        {
            first = j + 1;
        }
        i = pow(10, j + 1);
    }
    if (first == 0)
        tot++;
    for (int i = 1; i < first; i++)
    {
        N /= 10;
        mult *= 8;
    }
    for (int i = first; N; i++)
    {
        int pos = N % 10;
        if (N < 10)
            pos--;
        if (N > 9 && (N / 10) % 10 < N % 10)
            pos--;
        if (N > 99 && (N / 100) % 10 < N % 10)
            pos--;
        tot += pos * mult;
        N /= 10;
        if (N > 9)
            mult *= 8;
        else
            mult *= 9;
    }
    mult = 9;
    for (int i = 0; i < var; i++)
    {
        if (i == 0)
            tot++;
        tot += mult;
        if (i == 1)
            mult *= 9;
        else
            mult *= 8;
    }
    return tot;
}
int main()
{
    long long a, b;
    cin >> a >> b;
    cout << nb(b) - nb(a - 1) << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Correct 0 ms 436 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 412 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Incorrect 1 ms 604 KB Output isn't correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 0 ms 348 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 432 KB Output isn't correct
8 Incorrect 0 ms 352 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 436 KB Output isn't correct
11 Correct 1 ms 440 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 0 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 0 ms 344 KB Output isn't correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 352 KB Output is correct
18 Correct 0 ms 352 KB Output is correct
19 Correct 0 ms 352 KB Output is correct
20 Correct 0 ms 356 KB Output is correct
21 Correct 0 ms 356 KB Output is correct
22 Correct 0 ms 356 KB Output is correct
23 Correct 0 ms 356 KB Output is correct
24 Correct 0 ms 356 KB Output is correct
25 Correct 0 ms 356 KB Output is correct
26 Correct 0 ms 356 KB Output is correct
27 Correct 0 ms 356 KB Output is correct
28 Correct 0 ms 356 KB Output is correct
29 Correct 0 ms 352 KB Output is correct
30 Correct 0 ms 360 KB Output is correct
31 Correct 0 ms 360 KB Output is correct
32 Correct 0 ms 360 KB Output is correct
33 Correct 0 ms 360 KB Output is correct
34 Correct 0 ms 444 KB Output is correct
35 Correct 0 ms 360 KB Output is correct
36 Correct 0 ms 360 KB Output is correct
37 Correct 0 ms 448 KB Output is correct
38 Correct 0 ms 352 KB Output is correct
39 Correct 0 ms 356 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 360 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct