Logo
(追記) (追記ここまで)

26540번 - Bloom 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB111753771.154%

문제

Your garden is coming along very nicely, and you’ve grown curious as to when all of your different plants will be blooming. In order to ease your curiosity, you’ve pulled the seed bags out of the trash and found each plants’ growth cycle on the back of their bag. Given the growth cycle of everything you planted, determine how many plants will be blooming on each day.

Plants grow in different stages, and a plant’s growth cycle is simply a list of how many days each of these stages take to complete. For example, a plant with a growth cycle of 1 2 4 3 5 would bloom on day 15. Note, the first number in the list is stage 0 (zero).

One added complication is that some plants can be harvested more than once. For example, a plant with a growth cycle of 1 2 4 3 5 that returns to stage 2 after harvest would bloom on days 15, 27, 39, and so on.

입력

The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will start with a single integer x denoting how many plants there are. The next x lines will each consist of one plant’s growth cycle, denoted by an unknown number of integers. The last integer on each line will represent which stage in growth a plant returns to after blooming, or will be negative one if the plant can only be harvested once. The final line of each test case will consist of one integer, representing the day in question.

출력

For each test case, output the number of plants blooming on the given day.

제한

예제 입력 1

2
3
1 2 3 4 5 0
1 2 3 2
5 5 5 5 5 5 -1
30
3
1 2 3 4 5 0
1 2 3 2
5 5 5 5 5 5 -1
15

예제 출력 1

3
2

힌트

출처

School > PLU High School Programming Contest > PLU 2017 > Advanced 8번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /