QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#279228#5503. Euclidean Algorithmkilo_tobo_tarjenRE 0ms0kbC++20622b2023-12-08 14:28:492023-12-08 14:28:50

Judging History

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

  • [2023-12-08 14:28:50]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-12-08 14:28:49]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
const char el = '\n';
typedef long long ll;
ll solve2(ll n) {
  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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3
2
5
14

output:


result: