아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Polynomial

시간 제한3초메모리 제한256 MB

요약
차수가 20 이하인 0과 1 계수 다항식 P와 매우 큰 n이 주어질 때, P(x)^n에서 홀수인 계수의 개수를 구한다.
난이도

보통10점 중 7점

유형
조합론, 수학, 비트 연산
정답자
아직 제출이 없습니다

문제

Given a polynomial PP with coefficients from 0,1\\{0, 1\\}, print the number of odd coefficients in its nn-th power.

입력

The first line contains an integer dd (1≤d≤201 \le d \le 20) --- the degree of the polynomial.

The second line contains d+1d+1 integers a_ia\_i (a_i∈0,1a\_i \in \\{0, 1\\}), denoting the coefficients of PP from lowest to greatest.

The third line contains an integer nn (1≤n≤10161 \le n \le 10^{16}).

출력

Print the answer to the problem in the only line.

힌트

In the first sample test P(x)3=1+3x+3x2+x3P(x)^3 = 1 + 3x + 3x^2 + x^3, having all 4 coefficients odd.

예제2

  1. 예제 1

    입력
    1
    1 1
    3
    
    예상 출력
    4
    
  2. 예제 2

    입력
    5
    0 1 1 0 1 1
    3
    
    예상 출력
    10