QOJ.ac

QOJ

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

#22816. Bases negativas

Statistics

Bases negativas são como positivas, mas valores de posição alternados são negativos.

Sete em base dois positiva é $111_2$. Na base menos dois, os valores fazem $7$ ser $11011_{-2}$, pois $1\cdot16+1\cdot(-8)+0\cdot4+1\cdot(-2)+1=7$.

Bases negativas representam inteiros positivos e negativos sem sinal. Nesta tarefa essas representações não usam sinal. Converta um inteiro comum à base dada.

Entrada

Uma linha com $N$ e $B$: $-30000\le N\le30000$ é o número a converter, em base $10$; a nova base satisfaz $-10\le B\le-2$ ou $2\le B\le10$.

Saída

Uma linha com a representação de $N$ na base $B$.

Exemplos

Entrada 1

7 -2

Saída 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.