QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 2 5 14