| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 648462 | glome | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 2 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
string num;
int dp[19][11][11][2];
int mod = 1e9 + 7;
int rec(int pos, int p1, int p2, int f) {
if(pos == num.size()) return 1;
if(dp[pos][p1][p2][f] != -1) return dp[pos][p1][p2][f];
int LIM = 9;
if(!f) LIM = num[pos] - '0';
int res = 0;
for (int i = 0; i<=LIM; i++) {
if(p1 == i || p2 == i) continue;
res += rec(pos+1, i, p1, (f || i < LIM));
if(res >= mod) res -= mod;
}
return dp[pos][p1][p2][f] = res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long A, B;
cin >> A >> B;
num = to_string(B);
if(A == 0) {
memset(dp, -1 ,sizeof(dp));
cout << rec(0, 10, 10, 0) << '\n';
}
else {
A--;
memset(dp, -1 ,sizeof(dp));
B = rec(0, 10, 10, 0);
memset(dp, -1, sizeof(dp)); num = to_string(A);
cout << B - rec(0, 10, 10, 0) << '\n';
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
