QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137368 | #5503. Euclidean Algorithm | duckier | WA | 13412ms | 3452kb | C++14 | 635b | 2023-08-10 11:24:47 | 2023-08-10 11:24:51 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int z, n;
signed main() {
cin >> z;
while (z--) {
cin >> n;
int pi = 0, ans = 0;
for (int r = 1; r <= n; r = n / (n / r) + 1) {
int nr = n / r;
for (int k = 2; k <= nr; k = ((nr - 1) / ((nr - 1) / k)) + 1) {
if ((nr - 1) / k == 0) {
break;
}
int nx = (nr - 1) / ((nr - 1) / k);
ans += (nr - 1) / k * (nx - k + 1);
}
}
for (int k = 2; k <= n; k = n / (n / k) + 1) {
int nk = n / k;
if (nk == 0) break;
int nx = n / (n / k);
ans += nk * (nx - k + 1);
}
cout << ans << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3448kb
input:
3 2 5 14
output:
1 9 62
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 13412ms
memory: 3452kb
input:
3 29107867360 65171672278 41641960535
output:
7265477234430 17306090338958 10686469945522
result:
wrong answer 1st lines differ - expected: '8921593237533', found: '7265477234430'