Submission #1120788

#TimeUsernameProblemLanguageResultExecution timeMemory
1120788OmarAlimammadzadePalindrome-Free Numbers (BOI13_numbers)C++17
41.67 / 100
1100 ms508 KiB
// author - alimammadzade #include <bits/stdc++.h> #define ll long long using namespace std; int free1(ll k) { string s = to_string(k); for (int i = 0; i < (int)s.size() - 1; i++) for (int j = i + 1; j < (int)s.size(); j++) { string a = s.substr(i, j - i + 1), b = a; reverse(b.begin(), b.end()); if (a == b) return 0; } return 1; } int free2(int k) { string s = to_string(k); for (int i = 0; i < (int)s.size() - 1; i++) for (int j = i + 1; j < (int)s.size(); j++) { string a = s.substr(i, j - i + 1), b = a; reverse(b.begin(), b.end()); if (a == b) return 0; } return 1; } signed main() { cin.tie(nullptr)->sync_with_stdio(false); // system("cls"), freopen("in.txt", "r", stdin); ll a, b, res = 0; cin >> a >> b; if (b - a <= 1e5) for (ll i = a; i <= b; i++) res += free1(i); else { int A = a; int B = b; for (int i = A; i <= B; i++) res += free2(i); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...