P15381 [GeeksforGeeks] Increment3807
普及-
题目描述

Given a base B and a number N in that base, increment the number by one and print the resulting number in that base only.

Example 1:
Input:
B = 2
N = 0010
Output:
11
Explanation:
(0010){2} = (2)10
2 + 1 = 3
(3)
= (11)2
Example 2:
Input:
B = 13
N = 2139
Output:
231A
Explanation:
(2319){13} = (81)10
81 + 1 = 82
(82)
} = (231A)_{13
Your Task:
You don't need to read input or print anything. Your task is to complete the function inc() which takes an integer B, a string N as input parameter and returns the string by incrementing the number by one in the same base.

Expected Time Complexity: O(log N)
Expected Space Complexity: O(1)

Constraints:
2 <= B <= 16
0000 <= N <= Max value in that base (e.g. 1111 for base 2, FFFF for base 16, etc.)

输入格式

见题面

输出格式

见题面

样例输入
B = 2 N = 0010
样例输出
11