Submission #796235

#TimeUsernameProblemLanguageResultExecution timeMemory
796235duyanhloveavPalindrome-Free Numbers (BOI13_numbers)C++17
52.92 / 100
1088 ms340 KiB
#include <bits/stdc++.h> using namespace std; const int N = 9 + 1e6; const long long oo = 7 + 1e18; #pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") long long pw[20]; string tostring(long long x) { string s; while (x > 0) { s = s + (char)(x % 10 + '0'); x /= 10; } reverse(begin(s), end(s)); return s; } void SaKaTa() { long long a, b; scanf("%lld%lld", &a, &b); pw[0] = 1; for (int i = 1; i <= 18; i++) { pw[i] = pw[i - 1] * 10; } long long ans = 0; // check (s[i], s[i + 1]), (s[i], s[i + 2]) for (long long i = a; i <= b;) { string s = tostring(i); s = s + 's'; long long check = -oo; for (int j = 0; j < s.size() - 2; j++) { if (s[j] == s[j + 1]) { check = s.size() - (j + 1) - 2; break; } else if (s[j] == s[j + 2]) { check = s.size() - (j + 2) - 2; break; } } if (check == -oo) { ++ans; check = 0; } i = (i / pw[check]) * pw[check] + pw[check]; } printf("%lld", ans); } int32_t main() { #define TASKNAME "numbers" cin.tie(0)->sync_with_stdio(0); if ( fopen( TASKNAME".inp", "r" ) ) { freopen (TASKNAME".inp", "r", stdin); freopen (TASKNAME".out", "w", stdout); } int testcase = 1; // scanf("%d", &testcase); while (testcase--) SaKaTa(); return 0; }

Compilation message (stderr)

numbers.cpp: In function 'void SaKaTa()':
numbers.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int j = 0; j < s.size() - 2; j++) {
      |                         ~~^~~~~~~~~~~~~~
numbers.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%lld%lld", &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
numbers.cpp: In function 'int32_t main()':
numbers.cpp:58:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen (TASKNAME".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
numbers.cpp:59:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |         freopen (TASKNAME".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...