Submission #1120223

#TimeUsernameProblemLanguageResultExecution timeMemory
1120223vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
20 / 100
1100 ms788 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld double const int INF = 1e18; const int mod = 12345; const int sz = 1e5 + 5; bool pal(string z) { int x = stoi(z); int xc = x; int cur = 1; int res = 0; while(xc > 0) { res += (cur * (xc % 10)); cur *= 10; xc /= 10; } return res == x; } bool f(int x) { string s; s = to_string(x); for(int i = 0;i < s.size() - 1;i++) { string c = ""; c += s[i]; for(int j = i + 1;j < s.size();j++) { c += s[j]; if(c[0] == c[c.size() - 1] && c[1] == c[c.size() - 2]){ if(pal(c)) return false; } } } return true; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); int a , b; cin >> a >> b; int ans = 0; for(int i = a;i <= b;i++) { if(f(i)) { ans++; } } cout << ans << endl; }

Compilation message (stderr)

numbers.cpp: In function 'bool f(long long int)':
numbers.cpp:31:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0;i < s.size() - 1;i++)
      |                   ~~^~~~~~~~~~~~~~
numbers.cpp:35:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j = i + 1;j < s.size();j++)
      |                           ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...