QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#279230#5503. Euclidean Algorithmkilo_tobo_tarjenRE 0ms0kbC++20643b2023-12-08 14:29:562023-12-08 14:29:58

Judging History

你现在查看的是最新测评结果

  • [2023-12-08 14:29:58]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-12-08 14:29:56]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
const char el = '\n';
typedef long long ll;
ll solve2(ll n) {
  if (!n) return 0;
  ll res = 0;
  for (ll l = 1, r = 1; l <= n; l = r + 1, r = n / (n / l)) {
    res += (r - l + 1) * (n / l);
  }
  return res;
}
ll solve1(ll n) {
  ll res = 0;
  for (ll l = 1, r = 1; l <= n; l = r + 1, r = n / (n / l)) {
    res += (r - l + 1) * solve2(n / l - 1);
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(15);
  int tt;
  cin >> tt;
  while (tt--) {
    ll n;
    cin >> n;
    cout << solve1(n) << el;
  }
  return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

3
2
5
14

output:


result: