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

31333번 - Composition of Polynomials 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB234214.286%

문제

You are given polynomials $f(x),ドル $g(x),ドル $h(x)$ over field $\mathbb{Z}/2\mathbb{Z}$.

Find the polynomial $f(g(x)) \bmod h(x)$.

입력

The first three lines of input contain polynomials $f,ドル $g$ and $h,ドル one per line. Each polynomial $p$ is descibed as $n$ $p_0$ $p_1$ $p_2$ $\dots$ $p_n$ (1ドル \le n \le 4000,ドル $p_i \in \{0, 1\}$ for all $i,ドル and $p_n = 1$). The polynomial $p(x)$ is then equal to $p_0 + p_1 x + p_2 x^2 + \dots + p_n x^n$.

출력

Print the resulting polynomial in the same format.

If the answer is the null polynomial, print it as "0 0".

제한

예제 입력 1

5 0 1 0 1 0 1
2 1 1 1
4 0 1 1 0 1

예제 출력 1

1 1 1

예제 입력 2

2 1 1 1
3 0 0 1 1
4 1 0 1 0 1

예제 출력 2

3 1 0 0 1

노트

Let us recall some definitions.

The field $\mathbb{Z}/2\mathbb{Z}$ is a set of two elements 0ドル$ and 1ドル$ where results of addition, subtraction, multiplication and division are remainders modulo 2ドル$ of the corresponding results for ordinary integers.

A polynomial $f(x)$ over this field is an expression of the form $f_n \cdot x^n + f_{n - 1} \cdot x^{n - 1} + \ldots + f_1 x + f_0,ドル where coefficients $f_n,ドル $\ldots,ドル $f_0$ are integers from $\mathbb{Z}/2\mathbb{Z},ドル and the variable $x$ can hold values from $\mathbb{Z}/2\mathbb{Z}$ too. The maximum integer $n$ such that $f_n \ne 0$ is called the degree of the polynomial $p(x)$.

Polynomials $a(x) = \sum \limits _k a_k x^k$ and $b(x) = \sum \limits _k b_k x^k$ are equal if $a_k$ и $b_k$ are equal for all $k$.

Addition and subtraction of polynomials are performed component-wise: $a(x) \pm b(x) = \sum \limits _k (a_k \pm b_k) \cdot x^k$.

The product of polynomials $a(x)$ and $b(x)$ is $c(x) = \sum \limits _k c_k x^k$ where $c_s = \sum \limits _{t = 0} ^{s} (a_t \cdot b_{s - t})$.

Polynomials can be divided by each other. For a non-null polynomial $b(x),ドル we say that $a(x) / b(x) = q(x)$ and $a(x) \bmod b(x) = r(x)$ if $q(x) \cdot b(x) + r(x) = a(x)$ and the degree of $r(x)$ is strictly less than the degree of $b(x)$. It can be shown that $q(x)$ and $r(x)$ are uniquely defined.

Composition $a(b(x))$ is the polynomial $\sum \limits _k a_k (b(x))^k$ where the power of a polynomial is defined via multiplication: $(b(x))^0 = 1,ドル $(b(x))^1 = b(x),ドル $(b(x))^p = b(x) \cdot (b(x))^{p - 1}$ for $p > 1$. To find the coefficients, expand the expression and sum the coefficients for the same powers of $x$.

출처

Contest > Open Cup > 2014/2015 Season > Stage 5: Grand Prix of Peterhof I번

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

출처

대학교 대회

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

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