Submission #121647

#TimeUsernameProblemLanguageResultExecution timeMemory
121647samsPalindrome-Free Numbers (BOI13_numbers)C++14
24.17 / 100
1091 ms396 KiB
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; ll a, b; //string a, b; int check(ll a) { int v[20]; int t = 0; int r = 0; while(a > 0) { ll c = a%10; t++; v[t] = c; a -= c; a /= 10; } for(int i = 2 ; i < t; ++i) { //cout << v[i] << " \n"[i == t]; if(v[i-1] == v[i+1]) r = 1; else if(v[i-1] == v[i] || v[i] == v[i+1]) r = 1; } return r; } int main() { int resp = 0; cin >> a >> b; ll c = a; while(a <= b) { //cout << a << '\n'; int x = check(a); //if(x == 1) cout << a << '\n'; resp += check(a); a++; } cout << b - c - resp + 1<< '\n'; }

Compilation message (stderr)

numbers.cpp: In function 'int main()':
numbers.cpp:41:7: warning: unused variable 'x' [-Wunused-variable]
   int x = check(a);
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...