#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std ;
long long st , en ;
long long dp[ 22 ][ 12 ][ 12 ][ 2 ] ;
vector < int > get ( long long x ) {
vector < int > aux ;
while ( x != 0 ) {
aux.push_back ( ( x % 10 ) ) ;
x /= 10 ;
}
vector < int > ret ;
int i ;
int sz = aux.size ( ) ;
for ( i = sz - 1 ; i >= 0 ; i -- ) {
ret.push_back ( aux[ i ] ) ;
}
return ret ;
}
long long f ( long long x ) {
vector < int > v = get ( x ) ;
int i , j , t , z , p ;
int n = v.size ( ) ;
for ( i = 0 ; i <= n ; i ++ ) {
for ( j = 0 ; j <= 10 ; j ++ ) {
for ( t = 0 ; t <= 10 ; t ++ ) {
for ( z = 0 ; z < 2 ; z ++ ) {
dp[ i ][ j ][ t ][ z ] = 0 ;
}
}
}
}
dp[ 0 ][ 10 ][ 10 ][ 1 ] = 1 ;
for ( i = 0 ; i < n ; i ++ ) {
for ( j = 0 ; j <= 10 ; j ++ ) {
for ( t = 0 ; t <= 10 ; t ++ ) {
for ( z = 0 ; z < 2 ; z ++ ) {
if ( dp[ i ][ j ][ t ][ z ] == 0 ) { continue ; }
if ( j == 10 && t == 10 ) {
dp[ i + 1 ][ j ][ t ][ 0 ] += dp[ i ][ j ][ t ][ z ] ;
}
if ( z == 0 ) {
for ( p = 0 ; p <= 9 ; p ++ ) {
if ( p == j || p == t ) { continue ; }
dp[ i + 1 ][ t ][ p ][ 0 ] += dp[ i ][ j ][ t ][ z ] ;
}
}
else {
for ( p = 0 ; p <= v[ i ] ; p ++ ) {
if ( p == j || p == t ) { continue ; }
int id = 0 ;
if ( p == v[ i ] ) { id = 1 ; }
dp[ i + 1 ][ t ][ p ][ id ] += dp[ i ][ j ][ t ][ z ] ;
}
}
}
}
}
}
long long ret = 0 ;
for ( j = 0 ; j <= 10 ; j ++ ) {
for ( t = 0 ; t <= 10 ; t ++ ) {
for ( z = 0 ; z < 2 ; z ++ ) {
ret += dp[ n ][ t ][ j ][ z ] ;
}
}
}
return ret ;
}
void input ( ) {
cin >> st >> en ;
}
void solve ( ) {
printf ( "%lld\n" , f ( en ) - f ( st - 1 ) ) ;
}
int main ( ) {
input ( ) ;
solve ( ) ;
return 0 ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
3 |
Correct |
0 ms |
2064 KB |
Output is correct |
4 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
9 |
Correct |
0 ms |
2064 KB |
Output is correct |
10 |
Correct |
0 ms |
2064 KB |
Output is correct |
11 |
Correct |
0 ms |
2064 KB |
Output is correct |
12 |
Correct |
0 ms |
2064 KB |
Output is correct |
13 |
Correct |
0 ms |
2064 KB |
Output is correct |
14 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
16 |
Correct |
0 ms |
2064 KB |
Output is correct |
17 |
Correct |
0 ms |
2064 KB |
Output is correct |
18 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
19 |
Correct |
0 ms |
2064 KB |
Output is correct |
20 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2064 KB |
Output is correct |
2 |
Correct |
0 ms |
2064 KB |
Output is correct |
3 |
Correct |
0 ms |
2064 KB |
Output is correct |
4 |
Correct |
0 ms |
2064 KB |
Output is correct |
5 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
6 |
Correct |
0 ms |
2064 KB |
Output is correct |
7 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
11 |
Correct |
0 ms |
2064 KB |
Output is correct |
12 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
2064 KB |
Output isn't correct |
16 |
Correct |
0 ms |
2064 KB |
Output is correct |
17 |
Correct |
0 ms |
2064 KB |
Output is correct |
18 |
Correct |
0 ms |
2064 KB |
Output is correct |
19 |
Correct |
0 ms |
2064 KB |
Output is correct |
20 |
Correct |
0 ms |
2064 KB |
Output is correct |
21 |
Correct |
0 ms |
2064 KB |
Output is correct |
22 |
Correct |
0 ms |
2064 KB |
Output is correct |
23 |
Correct |
0 ms |
2064 KB |
Output is correct |
24 |
Correct |
0 ms |
2064 KB |
Output is correct |
25 |
Correct |
0 ms |
2064 KB |
Output is correct |
26 |
Correct |
0 ms |
2064 KB |
Output is correct |
27 |
Correct |
0 ms |
2064 KB |
Output is correct |
28 |
Correct |
0 ms |
2064 KB |
Output is correct |
29 |
Correct |
0 ms |
2064 KB |
Output is correct |
30 |
Correct |
0 ms |
2064 KB |
Output is correct |
31 |
Correct |
0 ms |
2064 KB |
Output is correct |
32 |
Correct |
0 ms |
2064 KB |
Output is correct |
33 |
Correct |
0 ms |
2064 KB |
Output is correct |
34 |
Correct |
0 ms |
2064 KB |
Output is correct |
35 |
Correct |
0 ms |
2064 KB |
Output is correct |
36 |
Correct |
0 ms |
2064 KB |
Output is correct |
37 |
Correct |
0 ms |
2064 KB |
Output is correct |
38 |
Correct |
0 ms |
2064 KB |
Output is correct |
39 |
Correct |
0 ms |
2064 KB |
Output is correct |
40 |
Correct |
0 ms |
2064 KB |
Output is correct |
41 |
Correct |
0 ms |
2064 KB |
Output is correct |
42 |
Correct |
0 ms |
2064 KB |
Output is correct |
43 |
Correct |
0 ms |
2064 KB |
Output is correct |
44 |
Correct |
0 ms |
2064 KB |
Output is correct |
45 |
Correct |
0 ms |
2064 KB |
Output is correct |