Submission #1120378

#TimeUsernameProblemLanguageResultExecution timeMemory
1120378vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
44.17 / 100
1074 ms512 KiB
#include <bits/stdc++.h> using namespace std; bool isPalindrome(const string &str) { string s1 = str.substr(0, str.size() / 2 + str.size() % 2); string s2 = str.substr(str.size() / 2); reverse(s2.begin(), s2.end()); return s1 == s2; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int a, b, ans = 0; cin >> a >> b; for (int i = a; i <= b; i++) { string str = to_string(i); char ok = true; for (size_t i = 0; i < str.size(); i++) { for (size_t j = 2; j <= str.size() - i; j++) { string substr = str.substr(i, j); if (isPalindrome(substr)) { ok = false; break; } } if (!ok) { break; } } if (ok) { ans++; } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...