Submission #1120648

#TimeUsernameProblemLanguageResultExecution timeMemory
1120648vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
49.17 / 100
1094 ms512 KiB
#include <bits/stdc++.h>
using namespace std;

int a, b, ans = 0, n;
char *str = NULL;
size_t i, j, k, d, e;

void toString(char *&str, int n) {
  unsigned int size = ceil(log10(n)) + 2;
  if (str == NULL) {
    str = (char *)malloc(size * sizeof(char));
  } else {
    str = (char *)realloc(str, size * sizeof(char));
  }

  if (n == 0) {
    str[0] = '0';
    return;
  }

  for (size_t i = 0; n > 0; i++) {
    str[i] = '0' + n % 10;
    n /= 10;
  }
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> a >> b;

  for (n = a; n <= b; n++) {
    toString(str, n);

    for (i = 0; i < strlen(str); i++) {
      for (j = 2; j <= strlen(str) - i; j++) {
        e = j / 2;
        d = i + e + j % 2;

        for (k = i; k < d; k++) {
          if (str[k] != str[i + i + e + j - k - 2]) {
            break;
          }

          if (k == d - 1) {
            goto next;
          }
        }
      }
    }

    ans++;

  next:
    continue;
  }

  cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...