2013
11-09

# LC-Display

A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed, because he liked the LC-display of his calculator so much. So you decide to write a program that displays numbers in an LC-display-like style on his computer.

The input contains several lines, one for each number to be displayed. Each line contains two integers s, n (1 <= s <= 10, 0 <= n <= 99 999 999), where n is the number to be displayed and s is the size in which it shall be displayed.

The input file will be terminated by a line containing two zeros. This line should not be processed.

Output the numbers given in the input file in an LC-display-style using s “-” signs for the horizontal segments and s “|” signs for the vertical ones. Each digit occupies exactly s+2 columns and 2s+3 rows. (Be sure to fill all the white space occupied by the digits with blanks, also for the last digit.) There has to be exactly one column of blanks between two digits.

Output a blank line after each number. (You will find a sample of each digit in the sample output.)

2 12345
3 67890
0 0

      --   --        --
|    |    | |  | |
|    |    | |  | |
--   --   --   --
| |       |    |    |
| |       |    |    |
--   --        --

---   ---   ---   ---   ---
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
---         ---   ---
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
---         ---   ---   ---

import java.io.BufferedReader;
import java.io.IOException;

public class Main {

public static void main(String[] args) throws IOException {
System.in));
int s;
String[] ss;
String str;
String[] num = new String[] { "1111110", "0000110", "1011011",
"1001111", "0100111", "1101101", "1111101", "1000110",
"1111111", "1101111" };
char temp;
StringBuilder buff;
while (true) {
s = Integer.parseInt(ss[0]);
if (s == 0) {
break;
}
str = ss[1];
for (int i = 0; i < 5; i++) {
buff = new StringBuilder();
if (i == 0 || i == 2 || i == 4) {
for (int j = 0; j < str.length(); j++) {
buff.append(' ');
if (i == 0) {
temp = num[str.charAt(j) - '0'].charAt(0);
} else if (i == 2) {
temp = num[str.charAt(j) - '0'].charAt(6);
} else {
temp = num[str.charAt(j) - '0'].charAt(3);
}
if (temp == '1') {
for (int k = 0; k < s; k++) {
buff.append('-');
}
} else {
for (int k = 0; k < s; k++) {
buff.append(' ');
}
}
buff.append(' ');
buff.append(' ');
}
} else {
for (int j = 0; j < str.length(); j++) {
if (i == 1) {
temp = num[str.charAt(j) - '0'].charAt(1);
if (temp == '1') {
buff.append('|');
} else {
buff.append(' ');
}
for (int k = 0; k < s; k++) {
buff.append(' ');
}
temp = num[str.charAt(j) - '0'].charAt(5);
if (temp == '1') {
buff.append('|');
} else {
buff.append(' ');
}
} else {
temp = num[str.charAt(j) - '0'].charAt(2);
if (temp == '1') {
buff.append('|');
} else {
buff.append(' ');
}
for (int k = 0; k < s; k++) {
buff.append(' ');
}
temp = num[str.charAt(j) - '0'].charAt(4);
if (temp == '1') {
buff.append('|');
} else {
buff.append(' ');
}
}
buff.append(' ');
}
}
if (i == 0 || i == 2 || i == 4) {
System.out.println(buff);
} else {
for (int k = 0; k < s; k++) {
System.out.println(buff);
}
}
}
System.out.println();
}
}
}

1. 这道题这里的解法最坏情况似乎应该是指数的。回溯的时候
O(n) = O(n-1) + O(n-2) + ….
O(n-1) = O(n-2) + O(n-3)+ …
O(n) – O(n-1) = O(n-1)
O(n) = 2O(n-1)

2. bottes vernies blanches

I appreciate the efforts you men and women place in to share blogs on such sort of matters, it was certainly useful. Keep Posting!

3. Excellent Web-site! I required to ask if I might webpages and use a component of the net web website and use a number of factors for just about any faculty process. Please notify me through email regardless of whether that would be excellent. Many thanks