#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0LL, sizeof x)
#define rng() (rand() >> 3)*rand()
int x, y, d, p;
ll dp[11][11][20][2];
ll solve(ll X){
if (X<0) return 0;
drain(dp);
dp[10][10][0][0]=1;
for(int l=0; X>0; ++l){
p=l+1;
d=X%10; X/=10;
fox(l2, 10){
fox(l3, 11){
if (l3==l2) continue;
fox(l4, 11){
if (l4==l2) continue;
if (l2<d)
dp[l2][l3][l+1][0]+=dp[l3][l4][l][0]+dp[l3][l4][l][1];
if (l2>d)
dp[l2][l3][l+1][1]+=dp[l3][l4][l][0]+dp[l3][l4][l][1];
if (l2==d){
dp[l2][l3][l+1][1]+=dp[l3][l4][l][1];
dp[l2][l3][l+1][0]+=dp[l3][l4][l][0];
}
}
}
}
}
ll ans=0;
fox(l, 11){
fox(l2, 11){
ans+=dp[l][l2][p][0];
}
}
//cout << ans << endl;
return ans;
}
int main(){
cin >> x >> y;
cout << solve(y)-solve(x-1) << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
5 |
Correct |
0 ms |
2052 KB |
Output is correct |
6 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
9 |
Correct |
0 ms |
2052 KB |
Output is correct |
10 |
Correct |
0 ms |
2052 KB |
Output is correct |
11 |
Correct |
0 ms |
2052 KB |
Output is correct |
12 |
Correct |
0 ms |
2052 KB |
Output is correct |
13 |
Correct |
0 ms |
2052 KB |
Output is correct |
14 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
16 |
Correct |
0 ms |
2052 KB |
Output is correct |
17 |
Correct |
0 ms |
2052 KB |
Output is correct |
18 |
Correct |
0 ms |
2052 KB |
Output is correct |
19 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
20 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2052 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
6 |
Correct |
0 ms |
2052 KB |
Output is correct |
7 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
11 |
Correct |
0 ms |
2052 KB |
Output is correct |
12 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
17 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
20 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
21 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
22 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
23 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
24 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
25 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
27 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
28 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
29 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
30 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
33 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
34 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
35 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
36 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
37 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
38 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
39 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
40 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
42 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
43 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
44 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |
45 |
Incorrect |
0 ms |
2052 KB |
Output isn't correct |