답안 #283166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
283166 2020-08-25T10:47:37 Z altalk Palindrome-Free Numbers (BOI13_numbers) C++14
8.75 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#define loop(a, b) for(int a = 0; a < b; ++a)
#define loop1(a, b) for(int a = 1; a <= b; ++a)
#define loopc(a, c, b) for(int a = c; a < b; ++a)
#define loopr(a, b) for(int a = b-1; a >= 0; --a)
#define mp make_pair

using namespace std;

typedef unsigned long long ull;

vector<int> aa, bb;
ull ai, bi, p, av=0, bv=0, v;
set<int> pos;
int prev=-1, prev2=-1, as, bs;

int main() {
    cin >> ai >> bi;
    ++bi;
    loopr(a, ceil(log10(ai))) {
        p = 1;
        loop(w, a) p *= 10;
        aa.push_back((ai / p) % (ull)10);
        //cout << aa.back() << endl;
    }
    loopr(b, ceil(log10(bi))) {
        p = 1;
        loop(w, b) p *= 10;
        bb.push_back((bi / p) % (ull)10);
        //cout << bb.back() << endl;
    }

    loop(a, 10) pos.insert(a);

    as = aa.size();
    loop(a, as) {
        if (a == 0) {
            v = aa[0];
            if (as > 1) v *= 9;
            loopc(w, 2, as) v *= 8;
            av = v;
        }
        else {
            v = aa[a] - (int)(aa[a] > aa[a-1]);
            if (a > 1) v -= (int)(aa[a] > aa[a-2]);
            loopc(w, a+1, as) v *= 8;
            av += v;
        }
        //cout << av << endl;
    }

    bs = bb.size();
    loop(b, bs) {
        if (b == 0) {
            v = bb[0];
            if (bs > 1) v *= 9;
            loopc(w, 2, bs) v *= 8;
            bv = v;
        }
        else {
            v = bb[b] - (int)(bb[b] > bb[b-1]);
            if (b > 1) v -= (int)(bb[b] > bb[b-2]);
            loopc(w, b+1, bs) v *= 8;
            bv += v;
        }
        //cout << bv << endl;
    }

    cout << bv - av << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Correct 0 ms 256 KB Output is correct
6 Incorrect 0 ms 256 KB Output isn't correct
7 Incorrect 0 ms 256 KB Output isn't correct
8 Incorrect 1 ms 256 KB Output isn't correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Incorrect 1 ms 256 KB Output isn't correct
15 Incorrect 1 ms 256 KB Output isn't correct
16 Incorrect 0 ms 256 KB Output isn't correct
17 Correct 1 ms 256 KB Output is correct
18 Incorrect 0 ms 256 KB Output isn't correct
19 Incorrect 0 ms 256 KB Output isn't correct
20 Incorrect 1 ms 256 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Incorrect 0 ms 256 KB Output isn't correct
6 Incorrect 0 ms 256 KB Output isn't correct
7 Incorrect 0 ms 256 KB Output isn't correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Incorrect 0 ms 256 KB Output isn't correct
10 Incorrect 0 ms 256 KB Output isn't correct
11 Incorrect 0 ms 256 KB Output isn't correct
12 Incorrect 0 ms 256 KB Output isn't correct
13 Incorrect 0 ms 256 KB Output isn't correct
14 Incorrect 0 ms 256 KB Output isn't correct
15 Incorrect 1 ms 256 KB Output isn't correct
16 Incorrect 0 ms 256 KB Output isn't correct
17 Incorrect 1 ms 256 KB Output isn't correct
18 Incorrect 0 ms 256 KB Output isn't correct
19 Incorrect 0 ms 256 KB Output isn't correct
20 Incorrect 0 ms 256 KB Output isn't correct
21 Incorrect 0 ms 256 KB Output isn't correct
22 Incorrect 0 ms 256 KB Output isn't correct
23 Incorrect 1 ms 256 KB Output isn't correct
24 Incorrect 1 ms 256 KB Output isn't correct
25 Incorrect 0 ms 256 KB Output isn't correct
26 Incorrect 0 ms 256 KB Output isn't correct
27 Incorrect 0 ms 256 KB Output isn't correct
28 Incorrect 0 ms 256 KB Output isn't correct
29 Incorrect 0 ms 256 KB Output isn't correct
30 Incorrect 0 ms 256 KB Output isn't correct
31 Incorrect 0 ms 256 KB Output isn't correct
32 Incorrect 1 ms 256 KB Output isn't correct
33 Incorrect 0 ms 256 KB Output isn't correct
34 Incorrect 0 ms 256 KB Output isn't correct
35 Incorrect 0 ms 256 KB Output isn't correct
36 Incorrect 0 ms 256 KB Output isn't correct
37 Incorrect 0 ms 256 KB Output isn't correct
38 Incorrect 0 ms 256 KB Output isn't correct
39 Incorrect 0 ms 256 KB Output isn't correct
40 Incorrect 0 ms 256 KB Output isn't correct
41 Incorrect 0 ms 256 KB Output isn't correct
42 Incorrect 0 ms 256 KB Output isn't correct
43 Incorrect 0 ms 256 KB Output isn't correct
44 Incorrect 0 ms 256 KB Output isn't correct
45 Incorrect 0 ms 256 KB Output isn't correct