//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,dp[22][4][13][13];
int cev;
string s;
vector<int> v,vv;
inline int f(int sira,int al,int last2,int last1){
int cevv=0;
if(sira==(int)v.size())return 1;
if(~dp[sira][al][last2][last1])return dp[sira][al][last2][last1];
for(int i=0;i<=9;i++){
if(al==0 && i>v[sira])break;
if(i==last2 || i==last1)continue;
if(sira==0 && i==0)continue;
int yes=0;
if(i<v[sira])yes=1;
cevv=(cevv+f(sira+1,max(yes,al),last1,i));
}
return dp[sira][al][last2][last1]=cevv;
}
inline int f1(int sira,int al,int last2,int last1){
int cevv=0;
if(sira==(int)vv.size())return 1;
if(~dp[sira][al][last2][last1])return dp[sira][al][last2][last1];
for(int i=0;i<=9;i++){
if(al==0 && i>vv[sira])break;
if(i==last2 || i==last1)continue;
if(sira==0 && i==0)continue;
int yes=0;
if(i<vv[sira])yes=1;
cevv=(cevv+f1(sira+1,max(yes,al),last1,i));
}
return dp[sira][al][last2][last1]=cevv;
}
main(void){
scanf("%lld %lld",&n,&m);
n--;
while(n){
v.pb(n%10);
n/=10;
}
while(m){
vv.pb(m%10);
m/=10;
}
reverse(v.begin(),v.end());
reverse(vv.begin(),vv.end());
memset(dp,-1,sizeof(dp));
cev=-f(0,0,10,10);
memset(dp,-1,sizeof(dp));
printf("%lld\n",cev+f(0,0,10,10));
return 0;
}
Compilation message
numbers.cpp:66:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
66 | main(void){
| ^
numbers.cpp: In function 'int main()':
numbers.cpp:67:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
67 | scanf("%lld %lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
27 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
28 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
36 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
38 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
39 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
40 |
Correct |
1 ms |
384 KB |
Output is correct |
41 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
42 |
Correct |
1 ms |
384 KB |
Output is correct |
43 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
44 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
45 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |