제출 #1121358

#제출 시각아이디문제언어결과실행 시간메모리
1121358coolboy19521Palindrome-Free Numbers (BOI13_numbers)C++17
100 / 100
2 ms504 KiB
#include"bits/stdc++.h" using namespace std; using ll = long long; const int mxN = 19; const int mxD = 11; ll dp[mxN][mxD][mxD][2]; ll go(string& S, int i, int j, int k, int f) { if ("-1" == S) { return 0; } if ((int)size(S) == i) { return 1; } if (0 <= dp[i][j][k][f]) { return dp[i][j][k][f]; } ll& val = dp[i][j][k][f]; val = 0; if (0 == k) { val += go(S, i + 1, j, k, 0); } int st = 1 + (1 > k); int d = S[i] - '0' + 1; for (int l = st; l < mxD; l ++) { if (l ^ j && l ^ k) { if (l < d || 0 == f) { val += go(S, i + 1, k, l, 0); } else if (l == d) { val += go(S, i + 1, k, l, 1); } } } return val; } main() { ll a; string B; cin >> a >> B; string A = to_string(a - 1); memset(dp, 0xc0, sizeof(dp)); ll ans = go(B, 0, 0, 0, 1); memset(dp, 0xc0, sizeof(dp)); ans -= go(A, 0, 0, 0, 1); cout << ans << endl; }

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

numbers.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...