1 #include <iostream>2 #include <algorithm>34 using namespace std;56 const int MAXL = 1000;78 int n, k, ans[MAXL];910 int main(void)11 {12 cin >> n >> k;13 if (!n) cout << 0 << endl;14 else15 {16 int m = 0;17 while (n)18 {19 ans[m++] = (n % (-k) + k) % k;20 n = (ans[m - 1] - n) / k;21 }22 for (int i = m - 1; i >= 0; i--)23 cout << char(ans[i] >= 10 ?24 ans[i] + 'A' - 10 :25 ans[i] + '0');26 cout << endl;27 }28 return 0;29 }假设输入的 n 在 int 范围内,k 为不小于 2 且不大于 36 的正整数,完成下面的判断题和单选题:
判断题
该算法的时间复杂度为。
删除第 23 行的强制类型转换,程序的行为不变。
除非输入的 n 为 0,否则程序输出的字符数为 。 单选题
当输入为“100 7”时,输出为( )。
当输入为“-255 8”时,输出为( )。
当输入为“1000000 19”时,输出为( )。