# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
255603 | 2020-08-01T12:07:25 Z | amoo_safar | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 1 ms | 392 KB |
// Zende bad Shoma nasime faghat ! #include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " : " << x << '\n' using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pair<ll, ll> pll; const ll Mod = 1000000007LL; const int N = 20; const ll Inf = 2242545357980376863LL; const ll Log = 30; ll pw[N]; ll Solve(ll x){ if(x < 0) return 0; if(x == 0) return 1; vector<int> C; while(x){ C.pb(x % 10); x /= 10; } ll res = 1; for(int i = 0; i < C.size() - 1; i++) res *= 10; reverse(all(C)); for(int i = 0; i <= C.size(); i++){ if(i == C.size()){ res ++; break; } if(i == 0){ if(C.size() == 1) res += C[0] - 1; else res += (C[0] - 1) * 9ll * pw[C.size() - 2]; } else { for(int j = 0; j < C[i]; j++){ if(j == C[i - 1]) continue; if((i >= 2) && (j == C[i - 2])) continue; res += pw[C.size() - i - 1]; } } if((i >= 1) && (C[i] == C[i - 1])) break; if((i >= 2) && (C[i] == C[i - 2])) break; } return res; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); pw[0] = 1; for(int i = 1; i < N; i++) pw[i] = 8 * pw[i - 1]; ll a, b; cin >> a >> b; cout << Solve(b) - Solve(a - 1) << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 KB | Output isn't correct |
2 | Incorrect | 0 ms | 384 KB | Output isn't correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Incorrect | 0 ms | 384 KB | Output isn't correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Incorrect | 0 ms | 384 KB | Output isn't correct |
7 | Incorrect | 0 ms | 384 KB | Output isn't correct |
8 | Incorrect | 0 ms | 384 KB | Output isn't correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 392 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Incorrect | 0 ms | 384 KB | Output isn't correct |
15 | Incorrect | 0 ms | 384 KB | Output isn't correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Incorrect | 0 ms | 384 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Incorrect | 0 ms | 384 KB | Output isn't correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Incorrect | 0 ms | 384 KB | Output isn't correct |
8 | Incorrect | 0 ms | 384 KB | Output isn't correct |
9 | Incorrect | 0 ms | 384 KB | Output isn't correct |
10 | Incorrect | 0 ms | 384 KB | Output isn't correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Incorrect | 0 ms | 288 KB | Output isn't correct |
13 | Incorrect | 0 ms | 384 KB | Output isn't correct |
14 | Incorrect | 0 ms | 384 KB | Output isn't correct |
15 | Incorrect | 0 ms | 384 KB | Output isn't correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 288 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 0 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 0 ms | 384 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 0 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 0 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 384 KB | Output is correct |
35 | Correct | 0 ms | 384 KB | Output is correct |
36 | Correct | 0 ms | 384 KB | Output is correct |
37 | Correct | 0 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 0 ms | 384 KB | Output is correct |
40 | Correct | 0 ms | 384 KB | Output is correct |
41 | Correct | 0 ms | 384 KB | Output is correct |
42 | Correct | 0 ms | 384 KB | Output is correct |
43 | Correct | 0 ms | 384 KB | Output is correct |
44 | Correct | 0 ms | 384 KB | Output is correct |
45 | Correct | 0 ms | 384 KB | Output is correct |