問題一覧 > 教育的問題

No.2272 Polynomial Multiplication mod 258280327

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 27
作問者 : 👑 p-adic / テスター : hotman78
お気に入りにしたユーザー ProblemId : 8595 / 自分の提出
問題文最終更新日: 2023-03-08 12:39:18
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 384 (順位表) の他の問題:

Problem Statement

Polynomials $F(x)$ and $G(x)$ with non-negative integer coefficients are given as input.

Compute each coefficient of the polynomial $F(x) G(x)$, which has non-negative integer coefficients, modulo $258280327$.

Input

The input is given from standard input in $4$ lines in the following format:

  • Line $1$ contains the degree $N$ of $F$.
  • Line $2$ contains, for each non-negative integer $i$ not exceeding $N$, the coefficient $F_i$ of the degree-$i$ term of $F$, in increasing order of $i$, separated by single-byte spaces.
  • Line $3$ contains the degree $M$ of $G$.
  • Line $4$ contains, for each non-negative integer $j$ not exceeding $M$, the coefficient $G_j$ of the degree-$j$ term of $G$, in increasing order of $j$, separated by single-byte spaces.

Here, the degree of the zero polynomial is defined to be $0$.

Constraints

The input satisfies the following constraints:

  • $N$ is an integer satisfying $0 \leq N \leq 2 \times 10^5$
  • For any non-negative integer $i$ not exceeding $N$:
    • if $i = N \neq 0$, then $F_i$ is an integer satisfying $0 < F_i \leq 10^{18}$
    • otherwise, $F_i$ is an integer satisfying $0 \leq F_i \leq 10^{18}$
  • $M$ is an integer satisfying $0 \leq M \leq 2 \times 10^5$
  • For any non-negative integer $j$ not exceeding $M$:
    • if $j = M \neq 0$, then $G_j$ is an integer satisfying $0 < G_j \leq 10^{18}$
    • otherwise, $G_j$ is an integer satisfying $0 \leq G_j \leq 10^{18}$

Output

Output $2$ lines to standard output in the following format:

  • On line $1$, output the degree $L$ of $F(x) G(x)$.
  • On line $2$, output, for each non-negative integer $k$ not exceeding $L$, the coefficient of the degree-$k$ term of $F(x) G(x)$ modulo $258280327$, in increasing order of $k$, separated by single-byte spaces.

Print a newline at the end.

Sample

Sample 1
Input
1
0 1
1
0 1
Output
2
0 0 1

$\displaystyle (0 + 1x) \times (0 + 1x) = 0 + 0x + 1x^2 $

The coefficients $0,0,1$ modulo $258280327$ are $0,0,1$.

Sample 2
Input
1
50000 7
1
1 20000
Output
2
50000 225159026 140000

$\displaystyle (50000 + 7x) \times (1 + 20000x) = 50000 + 1000000007x + 140000x^2 $

The coefficients $50000,1000000007,140000$ modulo $258280327$ are $50000,225159026,1400000$.

Sample 3
Input
1
65536 1
1
1 15232
Output
2
65536 223403372 15232

$\displaystyle (65536 + 1x) \times (1 + 15232x) = 65536 + 998244353x + 15232x^2 $

The coefficients $65536,998244353,15232$ modulo $258280327$ are $65536,223403372,15232$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。