Submission
Status:
--------------------
Subtask/Task Score:
0/100
Score: 0
User: octoberhail
Problemset: Abacus
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-13 22:12:18
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin >> n;
// Collect digits up to 8 columns
vector<int> num(8, 0);
int idx = 0;
if (n == 0) {
num[0] = 0;
} else {
while (n > 0 && idx < 8) {
num[idx] = n % 10;
n /= 10;
++idx;
}
}
// Top border row (8 columns with '* ')
for (int i = 0; i < 8; i++) {
cout << "* ";
}
cout << "\n\n";
// Upper deck row 1: inactive state (value < 5)
for (int i = 7; i >= 0; --i) {
if (num[i] >= 5) {
cout << " ";
} else {
cout << "* ";
}
}
cout << "\n\n";
// Upper deck row 2: active state (value >= 5, touching center beam)
for (int i = 7; i >= 0; --i) {
if (num[i] >= 5) {
cout << "* ";
} else {
cout << " ";
}
}
cout << "\n\n";
// Center beam (-) length 17
for (int i = 0; i < 17; ++i) {
cout << "-";
}
cout << "\n\n";
// Lower deck representation
// Based on the problem's sample outputs, the lower deck consists of 5 rows below the center beam.
// Let's determine how many beads are pushed up for each column:
vector<int> lower_count(8, 0);
for (int i = 7; i >= 0; --i) {
if (num[i] >= 5) {
lower_count[i] = num[i] - 5;
} else {
lower_count[i] = num[i];
}
}
// Row 1 of lower deck (immediately below the center beam):
// If a column has >= 1 lower bead, it's pushed up to the beam (printed as " "), otherwise "* ".
for (int j = 7; j >= 0; --j) {
if (lower_count[j] >= 1) {
cout << " ";
} else {
cout << "* ";
}
}
cout << "\n\n";
// Rows 2 to 5 of the lower deck:
for (int r = 2; r <= 5; ++r) {
for (int j = 7; j >= 0; --j) {
// For row r, a bead is pushed up (empty " ") if lower_count[j] >= r,
// otherwise it rests at the bottom ("* ").
if (lower_count[j] >= r) {
cout << " ";
} else {
cout << "* ";
}
}
if (r < 5) {
cout << "\n\n";
}
}
return 0;
}