Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: pinto

Problemset: Abacus

Language: cpp

Time: 0.003 second

Submitted On: 2026-03-06 13:23:18

#include <iostream>
#include <string>
using namespace std;

const int COLS = 8;

int digitAt(const string& s, int c) {
    int idx = (int)s.size() - 1 - c;
    return (idx >= 0) ? (s[idx] - '0') : 0;
}

void compute(long long x) {
    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 < 3; row++) {
        string line = "";
        for (int c = COLS - 1; c >= 0; c--) {
            bool active = (digits[c] >= 5);
            bool showBead;
            if (row == 0)       showBead = true;
            else if (row == 1)  showBead = !active;
            else                showBead = active;
            line += showBead ? "* " : "  ";
        }
        size_t last = line.find_last_not_of(' ');
        cout << (last == string::npos ? "" : line.substr(0, last + 1)) << "\n";
    }

    // SEPARATOR
    cout << "-----------------\n";

    for (int row = 0; row < 6; row++) {
        string line = "";
        for (int c = COLS - 1; c >= 0; c--) {
            int earth = digits[c] % 5;
            bool showBead;
            if (row < earth)        showBead = true;
            else if (row == earth)  showBead = false;
            else                    showBead = true;
            line += showBead ? "* " : "  ";
        }
        size_t last = line.find_last_not_of(' ');
        cout << (last == string::npos ? "" : line.substr(0, last + 1)) << "\n";
    }
}

int main() {
    long long x;
    cin >> x;
    compute(x);
    return 0;
}