#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
ll dp[20][2][11][11][2];
void reset() {
memset(dp,-1,sizeof(dp));
}
ll solve(string s, int i, bool lower, int l0, int l1, bool started) {
int n = s.length();
if (i == n) {
return started;
} else {
ll &res = dp[i][lower][l0][l1][started];
if (~res) return res;
res = 0;
for (int d=0; d<=(lower?9:int(s[i]-'0')); d++) {
if (d==l0) continue;
if (d==l1) continue;
res += solve(s,i+1,lower||(d<int(s[i]-'0')), l1, d, started || (d>0));
}
return res;
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll a,b;
cin>>a>>b;
// [a,b]
--a;
reset();
ll res = solve(to_string(b),0,false,10,10,false);
reset();
res -= solve(to_string(a),0,false,10,10,false);
out(res);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
376 KB |
Output isn't correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
364 KB |
Output is correct |
18 |
Correct |
2 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
364 KB |
Output is correct |
20 |
Correct |
2 ms |
364 KB |
Output is correct |
21 |
Correct |
2 ms |
364 KB |
Output is correct |
22 |
Correct |
2 ms |
364 KB |
Output is correct |
23 |
Correct |
2 ms |
492 KB |
Output is correct |
24 |
Correct |
2 ms |
364 KB |
Output is correct |
25 |
Correct |
2 ms |
364 KB |
Output is correct |
26 |
Correct |
2 ms |
364 KB |
Output is correct |
27 |
Correct |
2 ms |
364 KB |
Output is correct |
28 |
Correct |
2 ms |
364 KB |
Output is correct |
29 |
Correct |
2 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
2 ms |
364 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
364 KB |
Output is correct |
34 |
Correct |
2 ms |
364 KB |
Output is correct |
35 |
Correct |
2 ms |
364 KB |
Output is correct |
36 |
Correct |
2 ms |
364 KB |
Output is correct |
37 |
Correct |
2 ms |
364 KB |
Output is correct |
38 |
Correct |
2 ms |
364 KB |
Output is correct |
39 |
Correct |
2 ms |
364 KB |
Output is correct |
40 |
Correct |
1 ms |
364 KB |
Output is correct |
41 |
Correct |
2 ms |
384 KB |
Output is correct |
42 |
Correct |
2 ms |
364 KB |
Output is correct |
43 |
Correct |
2 ms |
364 KB |
Output is correct |
44 |
Correct |
2 ms |
364 KB |
Output is correct |
45 |
Correct |
2 ms |
364 KB |
Output is correct |