#2487. 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 pp,there are exactly four cards whose value is pp:Spade(SS),Heart(HH),Club(CC) and Diamond(DD).There are no cards of other values.
By 「composite integer」,we mean integers that have more than 22 divisors.For example,66 is a composite integer,since it has 44 divisors:1122336677 is not a composite number,since 77 only has 22 divisors:11 and 77,Note that 11 is not composite (it has only 11 divisor).
Given a positive integer nn,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 nn?For example,if n=24n = 24,one way is 4S+6H+4C+10D4S + 6H + 4C + 10D,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 aa and bb,and you need to find out all the answers for n=a,n=a+1,,n=bn=a,n=a+1,\dots,n=b

输入格式

The input contains at most 2525 test cases.Each test case begins with 33 integers aabb and cc,where cc is the number of lost cards.The next line contains cc strings,representing the lost cards.Each card is formatted as valueSvalueSvalueHvalueHvalueCvalueC or valueDvalueD,where value is a composite integer.No two lost cards are the same.The input is terminated by a=b=c=0a = b = c = 0

输出格式

For each test case,print ba+1b-a+1 integers,one in each line.Since the numbers might be large,you should output each integer modulo 1×1061 \times 10^6.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 a=1,b=5×104a=1,b=5 \times 10^4 and c1×104c \le 1 \times 10^4.For other test cases,1ab100,0c101 \le a \le b \le 100,0 \le c \le 10

提示

湖南省第七届大学生程序设计大赛

题目来源

鸣谢刘汝佳先生授权使用