Skip to content

Instantly share code, notes, and snippets.

@lapla-cogito
Last active April 7, 2019 02:13
Show Gist options
  • Save lapla-cogito/30747b637daf6318e967434028a66b6c to your computer and use it in GitHub Desktop.
Save lapla-cogito/30747b637daf6318e967434028a66b6c to your computer and use it in GitHub Desktop.
#include "bits/stdc++.h"
using namespace std;
int main() {
long long n;
cin >> n;
for (long long k = 1; k <= n; ++k) {
string h;
cin >> h;
bool mon = 0;
vector<char>a, b;
for (int i = 0; i < h.length(); ++i) {
if (h[i] != '0') { mon = 1; }
if (h[i] == '4') {
a.push_back('1');
b.push_back('3');
}
else {
a.push_back(h[i]);
if (mon) { b.push_back('0'); }
}
}
cout << "Case #" << k << ":" << " ";
bool ok = false;
for (auto i : a) {
if (ok&&i == '0') { cout << i; }
else if (i != '0') { cout << i; ok = 1; }
}
cout << " ";
ok = 0;
for (auto i : b) {
if (ok&&i == '0') { cout << i; }
else if (i != '0') { cout << i; ok = 1; }
}
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment