QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#6179. Maximum Square Problem

Estadísticas

Given a quadratic function $f(x) = ax^2 + bx + c$. For $n$ positive integers $i$ satisfying $1 \leq i \leq n$, the corresponding values of the quadratic function are $f(1), f(2), \dots, f(n)$. In general, their product $\displaystyle \prod_{i=1}^n f(i)$ is not a perfect square. What is the largest perfect square that divides this product?

Maximum Square Problem: For a given quadratic function $f(x) = ax^2 + bx + c$, calculate the largest perfect square that divides $\displaystyle \prod_{i=1}^n f(i)$.

Input

The first line of input contains four integers $a, b, c, n$, representing the coefficients $a, b, c$ of the given quadratic function $f(x) = ax^2 + bx + c$ and the number of terms $n$ in the product.

Output

Output the largest perfect square that divides $\prod_{i=1}^n f(i)$, modulo $998\,244\,353$.

Examples

Input 1

1 2 3 4

Output 1

2916

Subtasks

For $100\%$ of the test data, $1 \leq a, n \leq 2 \times 10^5$ and $0 \leq b, c \leq 2 \times 10^5$.

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.