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

25772번 - Decoding The Message 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB111100.000%

문제

Aliens connected with people and sent a message containing the answer to "The Ultimate Question of Life, the Universe, and Everything".

People received $n$ bytes (integers from 0ドル$ to 255ドル$ inclusive). The decoding algorithm is the following:

  • Let us consider all $n!$ permutations of received bytes.
  • Consider each permutation as a number written in base 256ドル$. Numbers can be equal.
  • Multiply all these numbers modulo 65ドル,535円$.
  • The result is the decoded message!

For each byte $i,ドル you are given the number $c_i$ of received bytes $i$. Please decode the message.

입력

The first line contains a single integer $t$ (1ドル \leq t \leq 100$) --- the number of test cases. Description of test cases follows.

The first line of each test case contains a single integer $k$ (1ドル \leq k \leq 256$) --- the number of bytes $i$ such that $c_i \neq 0$.

Each of the next $k$ lines contains two integers $i,ドル $c_i$ (0ドル \leq i \leq 255,ドル 1ドル \leq c_i \leq 10^9$). It is guaranteed that all given values $i$ are different.

For all other 256ドル - k$ bytes, the numbers $c_i$ are equal to 0ドル$.

It is guaranteed that $\displaystyle \sum\limits_{i=0}^{255} c_i = n \leq 10^9$.

출력

For each test case, print a single integer --- the decoded message.

제한

예제 입력 1

5
1
42 1
2
0 1
1 1
1
239 2
2
1 1
2 1
3
1 1
2 2
3 2

예제 출력 1

42
256
514
1284
61726

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 7: HSE Koresha Contest K번

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

출처

대학교 대회

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

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