Submission

Status:

--------------------

Subtask/Task Score:

0/100

Score: 0

User: PEPSEALSEA

Problemset: Abacus

Language: cpp

Time: 0.003 second

Submitted On: 2025-12-07 15:00:53

#include <bits/stdc++.h>

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    if (!(cin >> n)) {
        return 0; 

    }

    string s = to_string(n);

    int num_digits = 8;
    string padded_s(num_digits - s.length(), '0');
    padded_s += s;

    vector<string> abacus_rows(10); 

    string center_rod(17, '-');

    string center_row = "";
    for (int i = 0; i < num_digits; ++i) {
        center_row += center_rod;
        if (i < num_digits - 1) {
            center_row += " "; 

        }
    }
    abacus_rows[4] = center_row; 

    vector<string> output_rows(10);

    output_rows[4] = center_row;

    string empty_bead(15, ' ');
    string bead(15, '*');

    for (int col = 0; col < num_digits; ++col) {
        int digit = padded_s[col] - '0';
        string prefix = (col == 0) ? "" : " "; 

        if (digit >= 5) {

            output_rows[3] += prefix + bead;

            for(int r = 0; r <= 2; ++r) {
                output_rows[r] += prefix + empty_bead;
            }
        } else {

            output_rows[0] += prefix + bead;

            for(int r = 1; r <= 3; ++r) {
                output_rows[r] += prefix + empty_bead;
            }
        }

        int lower_beads_in = digit % 5;

        for (int r = 5; r < 5 + lower_beads_in; ++r) {
            output_rows[r] += prefix + bead; 

        }

        for (int r = 5 + lower_beads_in; r < 9; ++r) {
            output_rows[r] += prefix + empty_bead; 

        }

        output_rows[9] += prefix + empty_bead;
    }

    for (const string& row : output_rows) {
        cout << row << endl;
    }

    return 0;
}