제출 #38658

#제출 시각아이디문제언어결과실행 시간메모리
38658nibnalinPalindrome-Free Numbers (BOI13_numbers)C++14
72.50 / 100
0 ms2104 KiB
#include <iostream> #include <cstdio> #include <vector> using namespace std; typedef long long int lli; const lli maxn = 20; lli memo[maxn][12][12][2][2]; string A[2]; inline bool ispal(lli x, lli y, lli z) { return ((y == z) || (x == z)); } lli DP(lli idx, lli prev, lli pprev, lli less, lli type) { if(idx == lli(A[type].size())) return 1; else if(memo[idx][prev][pprev][less][type] != -1) return memo[idx][prev][pprev][less][type]; else { lli res = 0, val = (less?9:lli(A[type][idx]-'0')); for(lli i = 0;i <= val;i++) { if(ispal(pprev, prev, i)) continue; res += DP(idx+1, i, prev, max(less, lli(i < val)), type); } return memo[idx][prev][pprev][less][type] = res; } } int main(void) { lli a, b; scanf("%lld%lld", &a, &b); A[0] = to_string(b), A[1] = to_string(a-1); for(lli i = 0;i < maxn;i++) { for(lli j = 0;j < 11;j++) { for(lli k = 0;k < 11;k++) { for(lli l = 0;l < 2;l++) memo[i][j][k][l][0] = memo[i][j][k][l][1] = -1; } } } lli res = DP(0, 10, 10, 0, 0)-DP(0, 10, 10, 0, 1); printf("%lld\n", res); }

컴파일 시 표준 에러 (stderr) 메시지

numbers.cpp: In function 'int main()':
numbers.cpp:34:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &a, &b);
                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...