Party

Party

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


Problem Description
Qscqesze is going to hold a blind date party.He takes n boys and m girls into consideration of invitation.Each of them gets a number as a1..an and b1..bm.
The party is in pairs.Everyone is required to choose an opposite sex who is also invited.Every one should be in an only pair.
Qscqesze knows everypair of them if they are willing to come together.
For better result,he wants to ascertain the invitation list to make everyone could gets it's partner.
After his assistant ascertain the invitation list,she writes down the list on a piece of paper.As she is careless,she just writes part of the list down. That is to say Qscqesze gets a piece of paper with incomplete invitation list.
Here comes q questions: how many kinds of paper he might get if all guest in complete list has common divisor gi?
 

Input
The first line contains a integer T,indicates the number of testcase.
In each testcase:
The first line contains there integer n m and q,indicates the number of boys ,the number of girls and the number of question.
The next n line contains one 0/1-strings,if the i-th string's j-th character is 1 means the i-th boy is willing to come with the j-th girl and vice versa.
The next line contains n integers, they are ai.
The next line contains m integers, they are bi.
The next line contains q integers,they are gi.
 

Output
For each test case, output a single line "Case #x: ans1 ans2 ... ansq", where x is the case number, starting from 1. And ans1..ansq is the answer.
 

Sample Input
  
  
1 3 3 2 010 111 010 4 2 6 8 12 5 2 3
 

Sample Output
  
  
Case #1: 23 3
Hint
1<=T<=100 1<=n,m<=20 n+m>=20的数据组数为3 1<=q<=10 1<=g,ai,bi<=1e9;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值