Submission

Status:

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

Subtask/Task Score:

0/100

Score: 0

User: chs_14

Problemset: Abacus

Language: cpp

Time: 0.004 second

Submitted On: 2025-12-12 12:01:29

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

int main() {
    cin.tie(0)->sync_with_stdio(0);

    vector<string> abacusBase(10, string(8, '*'));
    abacusBase[2] = string(8, ' ');
    abacusBase[3] = string(8, '-');
    abacusBase[4] = string(8, ' ');

    int n, current_ball_down, current_ball_up;
    cin >> n;

    for (int i = 0; i < 8; i++)
    {
        current_ball_down=pow(10, 7-i);
        current_ball_up=5*current_ball_down;

        //upper
        int index = 1;
        while (n>=current_ball_up)
        {

            abacusBase[index][i]=' ';
            abacusBase[index+1][i]='*';

            n-=current_ball_up;
            index--;
        }

        //lower
        index = 5;
        while (n>=current_ball_down)
        {

            abacusBase[index][i] = ' ';
            abacusBase[index-1][i] = '*';

            n-=current_ball_down;
            index++;
        }
    }


    //DEBUG
    for (string &str : abacusBase)
    {
        for (char &c : str)
        {
            cout << c << ' ';
        }
        cout << '\n';
    }


    return 0;
}