QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#4314. 多项式

统计

给定一个系数为 $\{0, 1\}$ 的多项式 $P$,输出其 $n$ 次幂中奇数系数的个数。

输入格式

第一行包含一个整数 $d$ ($1 \le d \le 20$),表示多项式的次数。 第二行包含 $d + 1$ 个整数 $a_i$ ($a_i \in \{0, 1\}$),表示 $P$ 从低次到高次的系数。 第三行包含一个整数 $n$ ($1 \le n \le 10^{16}$)。

输出格式

在唯一的一行中输出问题的答案。

样例

样例输入 1

1
1 1
3

样例输出 1

4

样例输入 2

5
0 1 1 0 1 1
3

样例输出 2

10

说明

在第一个样例测试中,$P(x)^3 = 1 + 3x + 3x^2 + x^3$,共有 4 个奇数系数。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.