# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
75269 | Sherazin | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 3 ms | 1144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long a, b, ans;
long long dp[20][15][15][2][2];
char A[20];
long long solve(int pos = 0, int a = 10, int b = 10, int f = 0, int st = 1) {
if(!A[pos]) return 1LL;
long long &ret = dp[pos][a][b][f][st];
if(~ret) return ret;
ret = 0;
int lim;
if(!f) lim = A[pos]-'0';
else lim = 9;
for(int i = 0; i <= lim; i++) {
if(i == a || i == b) continue;
if(!i && st) ret += solve(pos+1, 10, 10, 1, 1);
else ret += solve(pos+1, b, i, f|(i < lim), 0);
}
return ret;
}
int main() {
scanf("%lld %lld", &a, &b);
memset(dp, -1LL, sizeof dp);
sprintf(A, "%lld", b);
ans = solve();
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |