Submission
Status:
--------------------
Subtask/Task Score:
0/100
Score: 0
User: pinto
Problemset: Abacus
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-06 11:25:10
#include <iostream>
#include <string>
using namespace std;
int digitAt(const string& str, int col) {
int idx = (int)str.size() - 1 - col;
if (idx >= 0 && idx < (int)str.size())
return str[idx] - '0';
return 0;
}
void compute(long long x) {
const int COLS = 8;
string yay = to_string(x);
int digits[COLS];
for (int c = 0; c < COLS; c++)
digits[c] = digitAt(yay, c);
for (int row = 0; row < 2; row++) {
for (int c = COLS - 1; c >= 0; c--) {
bool active = (digits[c] >= 5);
bool showBead = active ? (row == 1) : (row == 0);
cout << (showBead ? "*" : " ");
}
cout << "\n";
}
// ── SEPARATOR BAR
cout << "-----------------" << "\n";
for (int row = 0; row < 5; row++) {
for (int c = COLS - 1; c >= 0; c--) {
int earthActive = digits[c] % 5; // 0-4 beads pushed up
bool showBead;
if (earthActive == 0) {
showBead = (row >= 1);
} else {
if (row < earthActive)
showBead = true; // active bead pushed up
else if (row == earthActive)
showBead = false; // gap between active & inactive
else
showBead = true; // inactive bead resting down
}
cout << (showBead ? "*" : " ");
}
cout << "\n";
}
}
int main() {
long long x;
cout << "Type a number (up to 8 digits): ";
cin >> x;
compute(x);
return 0;
}