이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
ll dp[20][2][11][11][2];
void reset() {
memset(dp,-1,sizeof(dp));
}
ll solve(string s, int i, bool lower, int l0, int l1, bool started) {
int n = s.length();
if (i == n) {
return started;
} else {
ll &res = dp[i][lower][l0][l1][started];
if (~res) return res;
res = 0;
for (int d=0; d<=(lower?9:int(s[i]-'0')); d++) {
if (d==l0) continue;
if (d==l1) continue;
res += solve(s,i+1,lower||(d<int(s[i]-'0')), l1, d, started || (d>0));
}
return res;
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll a,b;
cin>>a>>b;
// [a,b]
--a;
reset();
ll res = solve(to_string(b),0,false,10,10,false);
reset();
res -= solve(to_string(a),0,false,10,10,false);
out(res);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |