# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
75269 | 2018-09-09T04:53:06 Z | Sherazin | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 3 ms | 1144 KB |
#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(); if(a) { memset(dp, -1LL, sizeof dp); sprintf(A, "%lld", a-1); ans -= solve(); } printf("%lld\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 640 KB | Output is correct |
3 | Correct | 2 ms | 640 KB | Output is correct |
4 | Correct | 2 ms | 732 KB | Output is correct |
5 | Correct | 2 ms | 792 KB | Output is correct |
6 | Correct | 2 ms | 800 KB | Output is correct |
7 | Correct | 2 ms | 800 KB | Output is correct |
8 | Correct | 2 ms | 800 KB | Output is correct |
9 | Correct | 2 ms | 800 KB | Output is correct |
10 | Correct | 3 ms | 824 KB | Output is correct |
11 | Correct | 2 ms | 824 KB | Output is correct |
12 | Correct | 2 ms | 824 KB | Output is correct |
13 | Correct | 2 ms | 824 KB | Output is correct |
14 | Correct | 2 ms | 824 KB | Output is correct |
15 | Correct | 2 ms | 824 KB | Output is correct |
16 | Correct | 2 ms | 824 KB | Output is correct |
17 | Correct | 2 ms | 824 KB | Output is correct |
18 | Correct | 2 ms | 824 KB | Output is correct |
19 | Correct | 2 ms | 824 KB | Output is correct |
20 | Correct | 2 ms | 824 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 824 KB | Output is correct |
2 | Correct | 2 ms | 824 KB | Output is correct |
3 | Correct | 2 ms | 828 KB | Output is correct |
4 | Correct | 2 ms | 832 KB | Output is correct |
5 | Correct | 2 ms | 848 KB | Output is correct |
6 | Correct | 2 ms | 852 KB | Output is correct |
7 | Correct | 2 ms | 856 KB | Output is correct |
8 | Correct | 3 ms | 860 KB | Output is correct |
9 | Correct | 2 ms | 864 KB | Output is correct |
10 | Correct | 2 ms | 868 KB | Output is correct |
11 | Correct | 2 ms | 872 KB | Output is correct |
12 | Correct | 2 ms | 896 KB | Output is correct |
13 | Correct | 2 ms | 896 KB | Output is correct |
14 | Correct | 2 ms | 900 KB | Output is correct |
15 | Correct | 3 ms | 904 KB | Output is correct |
16 | Correct | 2 ms | 908 KB | Output is correct |
17 | Correct | 2 ms | 916 KB | Output is correct |
18 | Correct | 2 ms | 916 KB | Output is correct |
19 | Correct | 3 ms | 920 KB | Output is correct |
20 | Correct | 2 ms | 924 KB | Output is correct |
21 | Correct | 2 ms | 928 KB | Output is correct |
22 | Correct | 2 ms | 932 KB | Output is correct |
23 | Correct | 2 ms | 936 KB | Output is correct |
24 | Correct | 2 ms | 940 KB | Output is correct |
25 | Correct | 3 ms | 944 KB | Output is correct |
26 | Correct | 2 ms | 952 KB | Output is correct |
27 | Correct | 2 ms | 956 KB | Output is correct |
28 | Correct | 2 ms | 960 KB | Output is correct |
29 | Correct | 2 ms | 964 KB | Output is correct |
30 | Correct | 2 ms | 968 KB | Output is correct |
31 | Correct | 2 ms | 972 KB | Output is correct |
32 | Correct | 2 ms | 976 KB | Output is correct |
33 | Correct | 2 ms | 980 KB | Output is correct |
34 | Correct | 3 ms | 980 KB | Output is correct |
35 | Correct | 3 ms | 988 KB | Output is correct |
36 | Correct | 2 ms | 992 KB | Output is correct |
37 | Correct | 3 ms | 996 KB | Output is correct |
38 | Correct | 2 ms | 1000 KB | Output is correct |
39 | Correct | 2 ms | 1004 KB | Output is correct |
40 | Correct | 2 ms | 1012 KB | Output is correct |
41 | Correct | 2 ms | 1012 KB | Output is correct |
42 | Correct | 2 ms | 1144 KB | Output is correct |
43 | Correct | 3 ms | 1144 KB | Output is correct |
44 | Correct | 3 ms | 1144 KB | Output is correct |
45 | Correct | 2 ms | 1144 KB | Output is correct |