답안 #860152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860152 2023-10-11T20:03:03 Z raphaelp Palindrome-Free Numbers (BOI13_numbers) C++14
95 / 100
1 ms 360 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++;
    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 == 0)
            mult *= 9;
        else
            mult *= 8;
    }
    return tot;
}
int main()
{
    long long a, b;
    cin >> a >> b;
    cout << nb(b) - nb(a - 1) << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 356 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is 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 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 360 KB Output is correct
41 Correct 0 ms 360 KB Output is correct
42 Correct 1 ms 360 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 360 KB Output is correct