QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#279230 | #5503. Euclidean Algorithm | kilo_tobo_tarjen | RE | 0ms | 0kb | C++20 | 643b | 2023-12-08 14:29:56 | 2023-12-08 14:29:58 |
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