Packing Biscuits

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Aunty Khong is organising a competition with xx participants, and wants to give each participant a bag of biscuits. There are kk different types of biscuits, numbered from 00 to k1k-1. Each biscuit of type ii (0ik10 \leq i \leq k-1) has a tastiness value of 2i2^i. Aunty Khong has a\[i]a\[i] (possibly zero) biscuits of type ii in her pantry.

Each of Aunty Khong's bags will contain zero or more biscuits of each type. The total number of biscuits of type ii in all the bags must not exceed a\[i]a\[i]. The sum of tastiness values of all biscuits in a bag is called the total tastiness of the bag.

Help Aunty Khong find out how many different values of yy exist, such that it is possible to pack xx bags of biscuits, each having total tastiness equal to yy.

제한

  • 1k601 \leq k \leq 60
  • 1q10001 \leq q \leq 1000
  • 1x10181 \leq x \leq 10^{18}
  • 0a\[i]10180 \leq a\[i] \leq 10^{18} (for all 0ik10 \leq i \leq k-1)
  • For each call to count_tastiness, the sum of tastiness values of all biscuits in the pantry does not exceed 101810^{18}.