bzoj#P2487. Super Poker II
Super Poker II
题目描述
I have a set of super poker cards,consisting of an infinite number of cards.For each positive composite integer ,there are exactly four cards whose value is :Spade(),Heart(),Club() and Diamond().There are no cards of other values.
By 「composite integer」,we mean integers that have more than divisors.For example, is a composite integer,since it has divisors:,,,; is not a composite number,since only has divisors: and ,Note that is not composite (it has only divisor).
Given a positive integer ,how many ways can you pick up exactly one card from each suit (i.e. exactly one spade card,one heart card,one club card and one diamond card),so that the card values sum to ?For example,if ,one way is ,shown below:
Unfortunately,some of the cards are lost,but this makes the problem more interesting.To further make the problem even more interesting (and challenging!),I’ll give you two other positive integers and ,and you need to find out all the answers for .
输入格式
The input contains at most test cases.Each test case begins with integers , and ,where is the number of lost cards.The next line contains strings,representing the lost cards.Each card is formatted as ,, or ,where value is a composite integer.No two lost cards are the same.The input is terminated by .
输出格式
For each test case,print integers,one in each line.Since the numbers might be large,you should output each integer modulo .Print a blank line after each test case.
12 20 2
4S 6H
0 0 0
0
0
0
0
0
0
1
0
3
数据规模与约定
There will be at most one test case where and .For other test cases,.
提示
湖南省第七届大学生程序设计大赛
题目来源
鸣谢刘汝佳先生授权使用