• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codeforce Round #211 Div2 A

A. Soroban
time limit per test 1 second
memory limit per test 256 megabytes

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.

Input

The first line contains a single integer n (0 ≤ n < 109).

Output

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.

Sample test(s)
Input
2
Output
O-|OO-OO
Input
13
Output
O-|OOO-O O-|O-OOO
Input
720
Output
O-|-OOOO O-|OO-OO -O|OO-OO
 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include <map>
 3 #include <stack>
 4 #include <queue>
 5 #include <vector>
 6 #include <string>
 7 #include <cmath>
 8 #include <cstdio>
 9 #include <cstring>
10 #include <cstdlib>
11 #include <iostream>
12 #include <algorithm>
13 using namespace std;
14 #define maxn 1055
15 #define ll long long
16 #define mod 1000000007
17 #define INF 0x7fffffff
18 #define eps 1e-8
19 int n, m, k, sx, sy;
20 int a[maxn];
21 int b[maxn];
22 int main(){
23     //int t;
24     //scanf("%d", &t);
25     //while (t--){
26     //memset(a, 0, sizeof a);
27     //memset(b, 0, sizeof b);
28     scanf("%d", &n);
29     int i = 0;
30     memset(a, 0, sizeof a);
31     if (n == 0){ printf("O-|-OOOO\n"); return 0; }
32     while (n){
33         a[i++] = n % 10;
34         n /= 10;
35     }
36     for (int j = 0; j < i; j++){
37         if (a[j] < 5)printf("O-|");
38         else printf("-O|");
39         a[j] = a[j] % 5;
40         if (a[j] == 0)printf("-OOOO\n");
41         if (a[j] == 1)printf("O-OOO\n");
42         if (a[j] == 2)printf("OO-OO\n");
43         if (a[j] == 3)printf("OOO-O\n");
44         if (a[j] == 4)printf("OOOO-\n");
45     }
46     return 0;
47 }
View Code
posted @ 2013-11-11 18:34  HaibaraAi  阅读(176)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3