Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: MaYangPhanTe

Problemset: Abacus

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-19 14:01:32

#include <bits/stdc++.h>
using namespace std;

void check(int x, int i, vector<int> &top, vector<int> &bottom) {
    if (x < 5) top[i] = 0;
    else top[i] = 1;
    bottom[i] = x % 5;
    return;
}

void abacus() {
    string x;
    cin >> x;

    vector<int> top(8, 0);
    vector<int> bottom(8, 0);

// calculate
    int n = x.length();
    int space = 8 - n;

    for (int i = 0 ; i < n; i++) {

        check ((int) x[i] - (int) '0', space + i, top, bottom);
    }

// output

    //top
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 8; j++) {
            
            if ( i == 0) {
                cout << "* ";
                continue;
            }

            if ( i == 1) {
                if ( top[j] == 0) cout << "* ";
                else cout << "  ";
            }

            else if (i == 2) {
                if ( top[j] == 0) cout << "  ";
                else cout << "* ";
            }
        }
        cout << "\n";
    }

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

    //bottom
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 8; j++) {
            
            if (i == 5) {
                cout << "* ";
                continue;
            }

            if (bottom[j] > 0) cout << "* ";
            else if( bottom[j] == 0)  cout << "  ";
            else cout << "* ";
            
            bottom[j]--;

        }
        cout << "\n";
    }
}

int main() {
    abacus();
}