/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author win11905
*/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define long long long
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
class numbers {
private:
long a, b;
char inp[25];
long dp[25][11][11][2];
long solve(int n, int a, int b, bool st) {
long &val = dp[n][a][b][st];
if(~val) return val;
if(inp[n] == 10) return val = 1;
val = 0;
for(int i = 0; i <= (st ? 9 : inp[n]); ++i) {
if(i == a || i == b) continue;
if(i == 0 && a == 10 && b == 10) val += solve(n+1, a, b, true);
else val += solve(n+1, i, a, st || i != inp[n]);
}
return val;
}
long get(long val) {
if(val == -1) val++;
sprintf(inp, "%d", val);
for(int i = 0; ; ++i) {
if(inp[i]) inp[i] -= '0';
else {
inp[i] = 10;
break;
}
}
memset(dp, -1, sizeof dp);
return solve(0, 10, 10, 0);
}
public:
void solve(istream& cin, ostream& cout) {
cin >> a >> b;
cout << get(b) - get(a-1) << endl;
}
};
class Solver {
public:
void solve(std::istream& in, std::ostream& out) {
numbers *obj = new numbers();
obj->solve(in, out);
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
Solver solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
solver.solve(in, out);
return 0;
}
Compilation message
numbers.cpp: In member function 'long long int numbers::get(long long int)':
numbers.cpp:39:25: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
sprintf(inp, "%d", val);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
532 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
532 KB |
Output isn't correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
532 KB |
Output is correct |
7 |
Correct |
2 ms |
532 KB |
Output is correct |
8 |
Correct |
2 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
708 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
3 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
3 ms |
720 KB |
Output is correct |
14 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
720 KB |
Output is correct |
18 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
720 KB |
Output is correct |
2 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
5 |
Correct |
2 ms |
720 KB |
Output is correct |
6 |
Correct |
2 ms |
720 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
2 ms |
720 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
18 |
Correct |
2 ms |
720 KB |
Output is correct |
19 |
Incorrect |
3 ms |
720 KB |
Output isn't correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
21 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
24 |
Correct |
2 ms |
720 KB |
Output is correct |
25 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
26 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
27 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
28 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
29 |
Correct |
2 ms |
720 KB |
Output is correct |
30 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
31 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
33 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
34 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
35 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
36 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
38 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
39 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
40 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
42 |
Correct |
2 ms |
720 KB |
Output is correct |
43 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
44 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
45 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |