#P1450. [HAOI2008] 硬币购物

    ID: 442 远端评测题 1000ms 128MiB 尝试: 1 已通过: 1 难度: 7 上传者: 标签>动态规划,dp数学递推2008河南各省省选容斥

[HAOI2008] 硬币购物

Description

There are 44 types of coins with face values c1,c2,c3,c4c_1, c_2, c_3, c_4.

A person goes shopping nn times. For each purchase, they carry did_i coins of type ii and want to buy items worth an amount of ss. For each purchase, how many payment methods are there?

Input Format

The first line contains five integers, representing c1,c2,c3,c4,nc_1, c_2, c_3, c_4, n.

The next nn lines each contain five integers describing one purchase, representing d1,d2,d3,d4,sd_1, d_2, d_3, d_4, s.

Output Format

For each purchase, output one line with a single integer representing the answer.

1 2 5 10 2
3 2 3 1 10
1000 2 2 2 900

4
27

Hint

  • Constraints
    For 100%100\% of the testdata, 1ci,di,s1051 \leq c_i, d_i, s \leq 10^5, 1n10001 \leq n \leq 1000.

Translated by ChatGPT 5