QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22816. 음수 진법

Statistics

음수 진법은 양수 진법과 같지만 자리값이 한 자리씩 번갈아 음수입니다.

7은 양의 이진법에서 $111_2$입니다. 음의 이진법에서는 자리값에 따라 $7$이 $11011_{-2}$가 됩니다. $1\cdot16+1\cdot(-8)+0\cdot4+1\cdot(-2)+1=7$이기 때문입니다.

음수 진법은 부호 없이 양수와 음수 정수를 표현합니다. 이 문제의 음수 진법 표현은 부호를 쓰지 않습니다. 보통 정수를 주어진 진법으로 변환하세요.

입력

한 줄의 $N$과 $B$: $-30000\le N\le30000$는 $10$진법으로 주어진 변환할 수입니다. 새 진법은 $-10\le B\le-2$ 또는 $2\le B\le10$입니다.

출력

한 줄에 $N$을 $B$진법으로 표현한 값입니다.

예제

입력 1

7 -2

출력 1

11011

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.