QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#137368#5503. Euclidean AlgorithmduckierWA 13412ms3452kbC++14635b2023-08-10 11:24:472023-08-10 11:24:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 11:24:51]
  • 评测
  • 测评结果:WA
  • 用时:13412ms
  • 内存:3452kb
  • [2023-08-10 11:24:47]
  • 提交

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'