CF363A.Soroban
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You know that Japan is the country with almost the largest 'electronic devices per person' ratio. So you might be quite surprised to find out that the primary school in Japan teaches to count using a Soroban — an abacus developed in Japan. This phenomenon has its reasons, of course, but we are not going to speak about them. Let's have a look at the Soroban's construction.

Soroban consists of some number of rods, each rod contains five beads. We will assume that the rods are horizontal lines. One bead on each rod (the leftmost one) is divided from the others by a bar (the reckoning bar). This single bead is called go-dama and four others are ichi-damas. Each rod is responsible for representing a single digit from 0 to 9. We can obtain the value of a digit by following simple algorithm:
- Set the value of a digit equal to 0.
- If the go-dama is shifted to the right, add 5.
- Add the number of ichi-damas shifted to the left.
Thus, the upper rod on the picture shows digit 0, the middle one shows digit 2 and the lower one shows 7. We will consider the top rod to represent the last decimal digit of a number, so the picture shows number 720.
Write the program that prints the way Soroban shows the given number n.
你知道,日本是人均电子设备数量几乎最多的国家。因此,当你得知日本的小学教授学生使用算盘(即“算盘”,一种源自日本的计算工具)进行计数时,或许会感到非常惊讶。这种现象当然有其原因,但我们在此不作讨论。让我们来了解一下算盘的结构。

算盘由若干根横杆组成,每根横杆上有五颗珠子。我们假设这些横杆呈水平排列。每根横杆上有一颗珠子(最左侧的一颗)被一根横梁(即“计数梁”)与其他四颗珠子隔开。这颗单独的珠子称为“天珠”(go-dama),其余四颗称为“地珠”(ichi-damas)。每根横杆用于表示一个 0 到 9 的十进制数字。我们可通过如下简单算法确定某根横杆所表示的数字:
- 将该数字的初始值设为 0;
- 若天珠向右拨动,则加 5;
- 再加上向左拨动的地珠的颗数。
因此,图中上方横杆表示数字 0,中间横杆表示数字 2,下方横杆表示数字 7。我们约定:图中自上而下的横杆依次表示一个数字的各位,其中最上方的横杆代表个位(即最低位),故图中所示数字为 720。
请编写一个程序,输出算盘表示给定数字 $ n $ 的方式。
输入格式
The first line contains a single integer n (0 ≤ n < 109).
第一行包含一个整数 n(0 ≤ n < 109)。
输出格式
Print the description of the decimal digits of number n from the last one to the first one (as mentioned on the picture in the statement), one per line. Print the beads as large English letters 'O', rod pieces as character '-' and the reckoning bar as '|'. Print as many rods, as many digits are in the decimal representation of number n without leading zeroes. We can assume that number 0 has no leading zeroes.
从最后一个十进制数字到第一个十进制数字(如题面图片中所示),逐行打印数字 n 的算盘表示。用大写英文字母 'O' 表示算珠,用字符 '-' 表示算杆段,用 '|' 表示横梁。算杆的数量应等于数字 n 的十进制表示(不含前导零)的位数。我们可以认为数字 0 不含前导零。
输入输出样例
输入#1
2
输出#1
O-|OO-OO
输入#2
13
输出#2
O-|OOO-O O-|O-OOO
输入#3
720
输出#3
O-|-OOOO O-|OO-OO -O|OO-OO
输入解题思路,AI测评打分。不知道怎么写?