Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: qweqwe

Problemset: Abacus

Language: cpp

Time: 0.003 second

Submitted On: 2025-06-13 20:35:02

#include <bits/stdc++.h>
#define speed cin.tie(0)->sync_with_stdio(0)
using namespace std;

int main(){
	speed;
	string n;cin >> n;
	int ind=1;
	vector<pair<int,int>> abacus(8,{0,0});
	vector<bool> used(8,0),spac(8,0);
	for (int i=n.size()-1;i>=0;i--){
		abacus[8-ind].first=(n[i]-'0')/5;
		abacus[8-ind].second=(n[i]-'0')%5;
		ind++;
	}
	/*
	for (pair<int,int> i:abacus){
		cout << i.first << " " << i.second << "\n";
	}cout << "\n";
	*/
	for (int i=0;i<10;i++){
		if (!i) cout << "* * * * * * * *";
		if (i==3) cout << "-----------------";
		else if (i<3){
			for (int j=0;j<8;j++){
				int temp=abacus[j].first;
				if (!temp && i==1) cout << "* ";
				else if (i==1) cout << "  ";
				if (temp && i==2) cout << "* ";
				else if (i==2)cout << "  ";
			}
		}else if (i>3){
			for (int j=0;j<8;j++){
				int temp=abacus[j].second;
				if (temp){
					cout << "* ";
					abacus[j].second--;
					used[j]=1;
				}else if (spac[j]){
					cout << "* ";
				}
				else if (i>4 && !used[j]){
					cout << "* ";
				}else if (used[j] && temp==0){
					cout << "  ";
					spac[j]=1;
				}else{
					cout << "  ";
				}
			}
		}
		cout << "\n";
	}
	return 0;
}