测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A61525. 2020年信息学奥赛csp-j阅读程序题:#include <iostream>

编程题

题目描述

2020年信息学奥赛csp-j阅读程序题:

#include <iostream>
using namespace std;
long long n, ans;
int k, len;
long long d[1000000];
int main() {
  cin >> n >> k;
  d[0] = 0;
  len= 1;
  ans = 0;
  for (long long i = 0; i <n; ++i) {
    ++d[0];
    for (int j = 0; j + 1<len; ++j) {
      if (d[j] == k) {
        d[j] = 0;
        d[j + 1] += 1;
        ++ans;
      }
    }
    if (d[len- 1] == k) {
      d[len - 1] = 0;
      d[len] =1;
      ++len;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

假设输入的n是不超过2^62的正整数,k都是不超过10000的正整数,完成下面的判断题和单选题: