Untitled
user_9000366
plain_text
a year ago
832 B
11
Indexable
void Mesh_JOO() {
long long n;
cin >> n;
if (n >= 0) {
cout << n << "\n";
return;
}
string s = to_string(n);
if (s.size() == 1) {
cout << 0 << "\n";
return;
}
char ch = s.back();
s.pop_back();
string f = s;
f.pop_back();
f += ch;
long long x = stoi(f), y = stoi(s);
cout << max(x, y) << "\n";
}
//-----------------------------------------------
void Mesh_JOO() {
char last = 'a';
string s;
cin >> s;
int res = 0;
for (int i = 0; i < s.size(); ++i) {
if (s[i] > last) {
res += min(s[i] - last, 'z' - s[i] + last - 'a' + 1);
} else {
res += min(last - s[i], 'z' - last + s[i] - 'a' + 1);
}
last = s[i];
}
cout << res;
}Editor is loading...
Leave a Comment