
Since final is approaching, this week’s club problems were very very simple yet numerous, the number of participants has also decreased, making it somewhat boring.
This was the first problem I solved, I expected to solve it in 3 mins, but took 4 mins.
There are four cases:
1. If the lowest digit is already an even number, 0
2. If every digits are odd, -1
3. If the lowest digit is odd but the highest digit is even, simply reversing the entire number, 1
4. Otherwise first reverse an even number to the highest, then reverse the entire number, 2
// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#define Debug(x...) _debug_print_format(#x, x);
std::ifstream terminal("/dev/tty");
#define PP cerr<<"\033[1;30mpause...\e[0m",terminal.ignore();
#else
#define debug(x...)
#define Debug(x...)
#define PP
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define FIND(a, x) ((find(a.begin(),a.end(),(x))!=a.end())?1:0)
#define cmin(x,...) x=min({(x),__VA_ARGS__})
#define cmax(x,...) x=max({(x),__VA_ARGS__})
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define NaN (int)(0x8b88e1d0595d51d1)
#define double long double
#define int long long
#define uint unsigned long long
#define MAXN 200010
void solve() {
string s; cin >> s;
bool even = 0;
rep(i, 0, sz(s)) even |= (((s[i] - '0') & 1) == 0);
if (!even) {
cout << -1 << endl;
return;
}
if (((s[sz(s)-1] - '0') & 1) == 0) {
cout << 0 << endl;
return;
}
if (((s[0] - '0') & 1) == 0) {
cout << 1 << endl;
return;
}
cout << 2 << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int _; cin >> _;
while (_--) solve();
return 0;
}
Winningpluscasino? Sounds promising! Let’s hope it lives up to its name, eh? I’m feeling lucky tonight! Fingers crossed. Time to win at winningpluscasino
Heard OK9Casino’s pretty rad, eh? Gonna check it out for some cheeky spins later. Hopefully, lady luck’s on my side! Check them out yourself at ok9casino.
Hey guys, just tried out spinph7. Not bad, not bad at all! Solid selection of games and things ran pretty smoothly. I’d give it a go if you’re looking for something new. Check it out here: spinph7