BrokenLED

You know, there are more and more LED Displays used for show numbers in everywhere, a general product is like the left picture below, called as 7 segments LED, because it can show all the digitals from 0 to 9 with 7 segments as the right picture below.


There are many 7 segment LED displays in our restraint, so we can view the money left in our sunny card. Unfortunately, some displays always with one or more segment are broken, that means, the segment which should be light up when it display a digital can't work. For example, if the 'a' segment is broken, then '7' and '1' will be displayed as '1' either. 
Now, Bob who is standing on front of a broken LED display want to know, how many possible results would be the number on the display. For example, with a LED display which it's all 'a' segments were broken, "11" would be 4 possible results which are "11", "17", "71" and "77". Note that pre-zeros are valid, for example, "0001" is equal to "1" or "01". 

Input

There are multiply test cases, every case start with a single integers N in the first line, that is how many LED in this case, the second line is a string shows which segment is broken in the LED from 'a' to 'g', good segment will replace as '-', the follow N lines will hold a string in each line to show numbers from left to right, which shows the lighted segment in the i-th LED. (1 <= N <= 9) 
Input will end with a single line which N == -1.

Output

For each test case, output an integer that how many possible numbers should be the LEDs described by the input in a single line.

Sample Input

2 
a------ 
--c--f- 
--c--f- 
-1 

Sample Output

Case 1: 4
#include<cstdio>
#include<cstring>
using namespace std;
char map[10][10]={"abc-efg","--c--f-","a-cde-g","a-cd-fg","-bcd-f-","ab-d-fg","ab-defg","a-c--f-","abcdefg","abcd-fg"};
char book[10];
char s[10];
int main(){
	int n;
	int cnt=0;
	while(scanf("%d",&n)){
		if(n==-1) break;
		scanf("%s",book);
		long long ans=1;
		for(int k=1;k<=n;k++){
			int t=0;
			scanf("%s",s);
			for(int i=0;i<=9;i++){
				bool flag=true;
				for(int j=0;j<7;j++){
					if(map[i][j]!='-'&&s[j]=='-'&&book[j]=='-'){//这个位置应该亮,但是没亮,而且也没坏 
						flag=false;
						break;
					}
					if(map[i][j]=='-'&&s[j]!='-'){//这个位置不应该亮,但是亮了 
						flag=false;
						break;
					}
				}
				if(flag) t++;
			}
			ans*=t;
		}
		printf("Case %d: %lld\n",++cnt,ans);
	}
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值