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$ だからです。

負の基数は符号なしで正負の整数を表せます。この問題の負の基数の表記には符号を使いません。普通の整数を指定の基数に変換してください。

入力

1 行に 2 整数 $N$ と $B$。$-30000\le N\le30000$ は基数 $10$ で表した変換対象です。新しい基数は $-10\le B\le-2$ または $2\le B\le10$ です。

出力

1 行に $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.