QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#77059 | #5503. Euclidean Algorithm | Golovanov399 | TL | 2ms | 3304kb | C++20 | 631b | 2023-02-13 00:57:34 | 2023-02-13 00:57:35 |
Judging History
answer
#include <iostream>
using namespace std;
int nxt() {
int x;
cin >> x;
return x;
}
long long f(long long n) {
n -= 1;
long long ans = 0;
for (long long d = 1; d <= n; d = n / (n / d) + 1) {
long long k = n / d;
ans += (n / k - d + 1) * k;
}
return ans;
}
void solve() {
long long n;
cin >> n;
long long ans = 0;
for (long long d = 1; d <= n; d = n / (n / d) + 1) {
long long k = n / d;
ans += (n / k - d + 1) * f(k);
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = nxt();
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3304kb
input:
3 2 5 14
output:
1 9 62
result:
ok 3 lines
Test #2:
score: -100
Time Limit Exceeded
input:
3 29107867360 65171672278 41641960535