#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}
ll dp[20][11][11][2];
vector<int> v;
ll rec(int i , int l1 , int l2 , int p){
if(i == (int)v.size()){
return 1;
}
if(dp[i][l1][l2][p]!=-1)return dp[i][l1][l2][p];
int last = 9;
if(p == 1)last = v[i];
ll res = 0;
for(int j = 0; j <= last; j++){
if(j != l1 && j != l2){
if(j == last){
res += rec(i + 1 , j , l1 , p);
}
else res += rec(i + 1 , j , l1 , 0);
}
}
return dp[i][l1][l2][p] = res;
}
void removedigits(ll x){
v.clear();
while(x){
v.pb(x % 10);
x /= 10;
}
reverse(all(v));
}
void solve(){
ll a , b;
cin >> a >> b;
ll ans = 0;
removedigits(b);
memset(dp,-1,sizeof dp);
ans += rec(0 , 10 , 10 , 1);
removedigits(a-1);
memset(dp,-1,sizeof dp);
ans -= rec(0 , 10 , 10 , 1);
cout << ans << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//int t;cin >> t;while(t--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
9 |
Correct |
0 ms |
324 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
308 KB |
Output is correct |
20 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Incorrect |
0 ms |
316 KB |
Output isn't correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
320 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
332 KB |
Output is correct |
35 |
Correct |
1 ms |
332 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
328 KB |
Output is correct |
38 |
Correct |
1 ms |
332 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Correct |
1 ms |
332 KB |
Output is correct |
41 |
Correct |
1 ms |
332 KB |
Output is correct |
42 |
Correct |
1 ms |
332 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
1 ms |
332 KB |
Output is correct |
45 |
Correct |
1 ms |
332 KB |
Output is correct |