#include <bits/stdc++.h>
#pragma GCC optimize ("O4")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")
using namespace std;
#define int long long
#define ll long long
#define XX first
#define YY second
#define all (x) begin(x), end(x)
/**
#define cin fin
#define cout fout
ifstream cin ("pfn.in");
ofstream cout ("pfn.out");
**/
/**typedef double dbl;
typedef long double ldb;
typedef pair <int, int> pii;
typedef vector <int> vii;
typedef pair <double, int> pdi;**/
vector <int> v;
const int NMAX = 10;
const int VMAX = 1;
const int RMAX = 179;
int dp[2 * NMAX][VMAX + 1][VMAX + 1][VMAX + 1];
void constr (int val){
if (val < 10){
v.push_back(val);
return;
}
constr (val / 10);
v.push_back(val % 10);
}
int gigel (int i, int s, int t, int a, int b, int poz){
if (i == v.size())
return true;
if (dp[i][s][t][a] == -1)
return dp[i][s][t][a];
int idx = 9, sum = 0;
if (s == 0)
idx = v[i];
for (int in = 0; in <= idx; ++ in){
if (in == poz && t) continue;
if (a && in == b) continue;
sum += gigel (i + 1, s | (in < idx), t | (in > 0) , a | t , poz , in);
}
return dp[i][s][t][a] = sum;
}
int solve (int a){
if (a == -1)
return 0;
v.clear();
constr (a);
memset (dp, -1, sizeof dp);
return gigel (0, 0, 0,0,0,0);
}
signed main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int x, y;
cin >> x >> y;
cout << solve(y) - solve(x - 1);
return 0 ^ 0;
}
Compilation message
numbers.cpp: In function 'long long int gigel(long long int, long long int, long long int, long long int, long long int, long long int)':
numbers.cpp:40:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if (i == v.size())
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
27 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
28 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
36 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
38 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
39 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
44 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
45 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |