Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: echo1faust

Problemset: Abacus

Language: cpp

Time: 0.004 second

Submitted On: 2025-06-08 19:08:16

#include<bits/stdc++.h>

using namespace std;

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

    char abacus[9][8];
    
    for(int i=0;i<9;i++){

        if(i < 2 || i > 3){
            for(int j=0;j<8;j++){
                abacus[i][j] = '*';
            }
        }
        else{
            for(int j=0;j<8;j++){
                abacus[i][j] = ' ';
            }
        }
    }

    if(number){
        int num_digit = log10(number) + 1;
        int each_digit[num_digit];
        int temp = number;
        int pos = 0;
    
        while(temp > 0){
            int digit = temp % 10;
            each_digit[pos] = digit;
            temp /= 10;
            pos++;
        }

        for(int j=0;j<num_digit;j++){
            if(each_digit[j] >= 5){
                swap(abacus[1][j],abacus[2][j]);
                each_digit[j] -= 5;
            }
            swap(abacus[3][j],abacus[3 + each_digit[j]][j]);
        }
    }

    for(int i=0;i<9;i++){
        if(i == 3) cout << "-----------------\n";

        for(int j=7;j>=0;j--){
            cout << abacus[i][j];
            if( j > 0) cout << " ";
        }
        cout << '\n';
    }

    return 0;
}

/*
* * * * * * * *
\n* * * * * * *   
\n
\n-----------------
\n
\n* * * * * * * *
\n* * * * * * * *
\n* * * * * * * *
\n* * * * * * * *
* * * * * * * *
*/