QOJ.ac

QOJ

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

#22816. Cơ số âm

Statistics

Cơ số âm như cơ số dương nhưng giá trị vị trí âm ở các vị trí xen kẽ.

Bảy trong cơ số hai dương là $111_2$. Trong cơ số âm hai, giá trị vị trí biểu diễn $7$ thành $11011_{-2}$ vì $1\cdot16+1\cdot(-8)+0\cdot4+1\cdot(-2)+1=7$.

Cơ số âm biểu diễn số nguyên dương và âm không cần dấu. Biểu diễn cơ số âm ở đây không dùng dấu. Chuyển số nguyên thông thường sang cơ số cho trước.

Dữ liệu vào

Một dòng với $N$ và $B$: $-30000\le N\le30000$ là số cần chuyển, ở cơ số $10$; cơ số mới thỏa $-10\le B\le-2$ hoặc $2\le B\le10$.

Dữ liệu ra

Một dòng biểu diễn $N$ ở cơ số $B$.

Ví dụ

Dữ liệu vào 1

7 -2

Dữ liệu ra 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.