QOJ.ac

QOJ

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

#22816. Negative Number Bases

Statistics

Negative number bases are just like positive ones, except that every other place value is negative.

The number seven represented in positive base two is $111_2$. In base negative two, however, the place values mean that $7$ is represented as $11011_{-2}$. This is because $1\cdot16+1\cdot(-8)+0\cdot4+1\cdot(-2)+1=7$.

Negative number bases can represent both positive and negative integers without using a sign. Negative-base representations do not use a sign in this task. Write a program to convert an ordinary integer into the supplied base.

Input

A single line with two integers $N$ and $B$: $-30000\le N\le30000$ is the number to convert, expressed in base $10$; the new base satisfies $-10\le B\le-2$ or $2\le B\le10$.

Output

A single line containing the representation of $N$ in base $B$.

Examples

Input 1

7 -2

Output 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.