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

35020번 - Compact Encoding 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB161614100.000%

문제

Binary formats often use compact representations for integers. Consider writing a 32-bit unsigned integer to a file: you must always reserve 4 bytes to represent it (remember, 8 bits make one byte). However, in many real-life applications, integer values tend to be small. Writing these small values using a fixed 4-byte representation results in files that are mostly filled with zero bytes.

To make the representation more compact, we introduce the following encoding scheme. Each value is represented as a sequence of bytes $b_1, b_2, \ldots, b_k,ドル where each $b_i$ is an integer between 0ドル$ and 255ドル,ドル inclusive. The most significant bit of each byte serves as a continuation flag, and the lower 7ドル$ bits carry the actual data. If the continuation flag is 1ドル,ドル more bytes follow; for the last byte, it is 0ドル$. The representation is big-endian, meaning that $b_1$ contains the most significant bits of the encoded value.

For example, here's how to find the compact representation of $n = 112025$. First, we find its binary representation:

112025ドル = 11011010110011001_2$

Next, we split it into 7-bit chunks, padding with zeros on the left if necessary:

0000110ドル$ / 1101011ドル$ / 0011001ドル$

The first two chunks have a following chunk, so the corresponding bytes have their most significant bit set to 1ドル$. The last chunk has no following chunk, so its most significant bit is 0ドル$. This gives us:

$b_1 = 10000110_2 = 134$

$b_2 = 11101011_2 = 235$

$b_3 = 00011001_2 = 25$

You are given an integer $n,ドル and your task is to find its compact representation.

입력

The only line contains a single integer $n$ (0ドル \le n \le 2^{31}-1$).

출력

Print a sequence of integers between 0ドル$ and 255ドル,ドル inclusive, representing the compact encoding of $n$. The encoding must not contain leading bytes with zero data bits: that is, it may not start with 128ドル$.

제한

예제 입력 1

112025

예제 출력 1

134 235 25

예제 입력 2

128

예제 출력 2

129 0

예제 입력 3

0

예제 출력 3

0

예제 입력 4

42

예제 출력 4

42

예제 입력 5

16384

예제 출력 5

129 128 0

예제 입력 6

2147483647

예제 출력 6

135 255 255 255 127

노트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2025-2026 Northwestern Russia Regional Contest C번

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

출처

대학교 대회

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

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