Kalel, the Jumping Frog
시간 제한18초메모리 제한1024 MB
길이 1에서 10까지, 각기 다른 에너지를 쓰는 점프를 사용해 개구리가 돌 1에서 돌 N까지 총 K 이하의 에너지로 도달하는 방법의 수를 10^9로 나눈 나머지를 구한다.
문제
Kalel is a frog that likes jumping over stones.
There are stones in a row, numbered from to from left to right. Kalel begins at stone and he wants to reach stone .
At each move, Kalel can choose among types of jump. The -th jump allows him to jump from stone to stone and costs energy points. It may happen that equals for some . You can assume Kalel never runs out of energy.
Given and , calculate in how many ways Kalel can reach stone spending at most energy points in total. Two ways are considered different if the sequence of jump choices is different. As this number can become very large, we are only interested in its remainder modulo (one billion).
입력
The first line contains three integers, , and (, , ). The next lines contain two integers each, the numbers and (, ).
출력
Print a single line, containing in how many different ways Kalel can get to the rock spending a maximum of energy points, modulus (one billion).