/**
* 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);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
388 KB |
Output is correct |
3 |
Incorrect |
2 ms |
448 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
628 KB |
Output isn't correct |
5 |
Correct |
2 ms |
628 KB |
Output is correct |
6 |
Correct |
2 ms |
628 KB |
Output is correct |
7 |
Correct |
3 ms |
628 KB |
Output is correct |
8 |
Correct |
2 ms |
628 KB |
Output is correct |
9 |
Correct |
2 ms |
628 KB |
Output is correct |
10 |
Correct |
2 ms |
628 KB |
Output is correct |
11 |
Correct |
2 ms |
628 KB |
Output is correct |
12 |
Correct |
3 ms |
636 KB |
Output is correct |
13 |
Correct |
2 ms |
668 KB |
Output is correct |
14 |
Incorrect |
2 ms |
672 KB |
Output isn't correct |
15 |
Correct |
2 ms |
692 KB |
Output is correct |
16 |
Correct |
2 ms |
696 KB |
Output is correct |
17 |
Correct |
2 ms |
704 KB |
Output is correct |
18 |
Incorrect |
3 ms |
704 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
708 KB |
Output isn't correct |
20 |
Correct |
3 ms |
712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
716 KB |
Output is correct |
2 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
728 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
728 KB |
Output isn't correct |
5 |
Correct |
3 ms |
732 KB |
Output is correct |
6 |
Correct |
2 ms |
736 KB |
Output is correct |
7 |
Correct |
2 ms |
740 KB |
Output is correct |
8 |
Correct |
2 ms |
744 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
812 KB |
Output is correct |
11 |
Correct |
3 ms |
812 KB |
Output is correct |
12 |
Correct |
2 ms |
812 KB |
Output is correct |
13 |
Correct |
3 ms |
812 KB |
Output is correct |
14 |
Correct |
3 ms |
812 KB |
Output is correct |
15 |
Correct |
2 ms |
812 KB |
Output is correct |
16 |
Incorrect |
2 ms |
812 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
812 KB |
Output isn't correct |
18 |
Correct |
2 ms |
812 KB |
Output is correct |
19 |
Incorrect |
2 ms |
812 KB |
Output isn't correct |
20 |
Correct |
3 ms |
812 KB |
Output is correct |
21 |
Incorrect |
2 ms |
812 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
812 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
812 KB |
Output isn't correct |
24 |
Correct |
2 ms |
812 KB |
Output is correct |
25 |
Incorrect |
2 ms |
812 KB |
Output isn't correct |
26 |
Incorrect |
3 ms |
816 KB |
Output isn't correct |
27 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
28 |
Incorrect |
2 ms |
824 KB |
Output isn't correct |
29 |
Correct |
2 ms |
828 KB |
Output is correct |
30 |
Incorrect |
2 ms |
836 KB |
Output isn't correct |
31 |
Incorrect |
2 ms |
836 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
840 KB |
Output isn't correct |
33 |
Incorrect |
2 ms |
844 KB |
Output isn't correct |
34 |
Incorrect |
2 ms |
848 KB |
Output isn't correct |
35 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
36 |
Incorrect |
2 ms |
856 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
860 KB |
Output isn't correct |
38 |
Incorrect |
2 ms |
864 KB |
Output isn't correct |
39 |
Incorrect |
2 ms |
872 KB |
Output isn't correct |
40 |
Incorrect |
2 ms |
872 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
876 KB |
Output isn't correct |
42 |
Correct |
2 ms |
880 KB |
Output is correct |
43 |
Incorrect |
2 ms |
884 KB |
Output isn't correct |
44 |
Incorrect |
2 ms |
888 KB |
Output isn't correct |
45 |
Incorrect |
2 ms |
892 KB |
Output isn't correct |