← 查看本卷题目
组合题6 个小题
已作答 0 / 6
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 的正整数,完成下面的判断题和单选题:

判断题

第28题判断题原卷 1.5 分

该算法的时间复杂度为O(log⁡kn)O(\log_k n)。

填写答案