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

18922번 - Disk Troubles 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB91291523.810%

문제

The Special String Storage (SSS) has a large bank of strings. For each string, its cyclic redundancy check code (CRC) is also stored. The hard disks at SSS are so reliable that each string has at most one corrupted bit.

Byteazar has to write a program that will repair such errors. To do that, he must solve the following problem.

Consider polynomials in one variable over the field $GF (2)$ (it means that the coefficients can be just 0ドル$ and 1ドル,ドル and all calculations for them are performed modulo 2ドル$). Let $P(x) = x^{32} + x^{26} + x^{15} + x^7 + 1$. The polynomial $P (x)$ has an amazing property: for any two distinct integers $i$ and $j$ such that 0ドル \le i, j < 2^{32},ドル the polynomials $x^i \bmod P (x)$ and $x^j \bmod P (x)$ are also distinct.

Here, $A (x) \bmod B (x)$ is the remainder of polynomial division of $A (x)$ by $B (x)$. Formally, we have $A (x) \bmod B (x) = R (x)$ where the highest degree of $x$ in $R (x)$ is strictly lower than the highest degree of $x$ in $B (x)$ and there exists a polynomial $Q (x)$ such that $A (x) = Q (x) \times B (x) + R (x)$. As with integer division, there exists exactly one such $Q (x)$ and exactly one $R (x)$ for any polynomial $A (x)$ and any non-zero polynomial $B (x)$. For example, $x^{32} \bmod P (x) = x^{26} + x^{15} + x^7 + 1$; here, $Q (x) = 1$.

For each given polynomial $Q (x),ドル Byteazar should find the minimal nonnegative $k$ such that $x^{k} \bmod P (x)$ is equal to $Q (x)$. Help him do it.

입력

The input consists of one or more test cases.

Each test case consists of single line containing a polynomial $Q (x)$. Each polynomial consists of one or more terms; consecutive terms are separated by character '+'. Each term is written as x^k where the power $k$ is an integer such that 0ドル \le k < 32$. All terms are distinct and given in the order of decreasing $k$. There are no spaces in the input.

There are at most 200ドル$ test cases. The input will be terminated by a line containing a single zero which should not be considered as a test case.

출력

For each test case, write a single line with the answer to the problem.

제한

예제 입력 1

x^0
x^1
x^26+x^15+x^7+x^0
x^26+x^21+x^15+x^13+x^7+x^6+x^0
x^31+x^25+x^14+x^6
0

예제 출력 1

0
1
32
38
4294967294

힌트

출처

Camp > Bytedance-Moscow Workshops Camp > Bytedance-Moscow Workshops Camp 2020 > Contest 1 D번

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

출처

대학교 대회

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

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