제출 #779116

#제출 시각아이디문제언어결과실행 시간메모리
779116adaawfPalindrome-Free Numbers (BOI13_numbers)C++14
58.75 / 100
2 ms512 KiB
#include <iostream> #include <cstring> using namespace std; string tostring(long long int a) { if (a == 0) return "0"; string res = ""; while (a != 0) { res = char(a % 10 + 48) + res; a /= 10; } return res; } long long int f[25][2][15][15][2]; long long int trya(string s, int i, int smaller, int x, int y, int flag) { if (i == s.size()) { return 1; } if (f[i][smaller][x][y][flag] != -1) return f[i][smaller][x][y][flag]; long long int h = 9, res = 0; if (smaller == 0) h = s[i] - '0'; for (int j = 0; j <= h; j++) { if (j == x || j == y) continue; res += trya(s, i + 1, smaller | (j != h), (flag == 0) ? 10 : j, x, flag | (j != 0)); } //cout << i << " " << smaller << " " << x << " " << y << " " << res << endl; f[i][smaller][x][y][flag] = res; return res; } int main() { long long int l, r; cin >> l >> r; l--; memset(f, -1, sizeof f); string s = tostring(r); long long int h = trya(s, 0, 0, 10, 10, 0), k; if (l < 0) { k = 0; } else { memset(f, -1, sizeof f); string t = tostring(l); k = trya(t, 0, 0, 10, 10, 0); } cout << h - k; }

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

numbers.cpp: In function 'long long int trya(std::string, int, int, int, int, int)':
numbers.cpp:15:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     if (i == s.size()) {
      |         ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...