资源描述
LED Display
Time Limit:1 Second Memory Limit:32768 KB
One day in the laboratory, Fred found some LED displays. This seven-segment LED can display digit 0 to 9 properly. But Fred soon find the LED have a serious problem, at the beginning, the seven bars were all on. But when one bar once was trun off, it can't be turn on again! So ecah LED only can display digit in certain oder. For example, one LED can display 9,3,7 successively, but can't display 2,4.
Now, Fred have a task to display a sequence of digit that is between 0 to 9. Because of the shortcoming of these LEDs, he need a number of them. But he also want to minimize the number, can you help him?
NOTE:If two digits in a sequece are the same,Fred want for the clearness, so he thought the latter digit can't be displayed on the same LED.
Input:
The input consists of several test cases. The first line of each test case contains a positive integer N (<=1000), then followed by a list of N digits. Each digit follows with a blank space.
Output:
For each test case, you must print a minimum number of LED that Fred need in one line.
Sample Input:
1
8
4
9 0 7 3
8
8 8 8 9 6 5 4 1
Sample Output:
1
2 (Hint:one mothod is display {9,3} on the first LED; {0,7} on the second)
3 (Hint:one possible solution is {8},{8,9,4,1},{8,6,5})
Author:JIANG, Dongming
大概意思:7个LED为一组表示一个数字(如图),每个LED打开关闭一次就不能再打开了。现在要用最少的LED表示一串数字,比如:
用6个LED可以表示“9”,然后关掉一个LED,可以表示“3”。但是这时不能用这一组LED表示“8”,因为有一个LED被关掉过不能再打开了,要想表示“8”就必须另用一组LED。
现在要表示“9073”这组数字,在第一个LED表示“9”和“3”,在第二个LED表示“0”和“7”。
题目要求就是任意给一组数字,要求程序能判断最少需要多少组LED。语言任意,运行时间少于1秒,内存少于32768 KB
展开阅读全文