| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 894614 | IWKR | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 2 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int dp[20][10][10][2][2][2];
int cal(int len, int l, int ll, bool bound, bool zero1, bool zero2, string target) {
if (len == target.size()) {
return 1;
}
if (dp[len][l][ll][bound][zero1][zero2] != -1) {
return dp[len][l][ll][bound][zero1][zero2];
}
int ans = 0;
for (int i = 0; i <= 9; i++) {
if ((!zero1 && i == l) || (!zero2 && i == ll)) {
continue;
} else {
if (bound && i > target[len] - '0') {
break;
}
ans += cal(len + 1, i, l, bound && (i == target[len] - '0'), i == 0 && zero1, zero1, target);
}
}
dp[len][l][ll][bound][zero1][zero2] = ans;
return ans;
}
int32_t main() {
int a, b;
cin >> a >> b;
string s = to_string(a - 1);
string t = to_string(b);
memset(dp, -1, sizeof dp);
int ans = cal(0, 0, 0, true, true, true, t);
memset(dp, -1, sizeof dp);
cout << ans - cal(0, 0, 0, true, true, true, s);
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
