QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138170#5503. Euclidean AlgorithmduckierRE 1ms3452kbC++142.5kb2023-08-11 05:12:552023-08-11 05:12:58

Judging History

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

  • [2023-08-11 05:12:58]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3452kb
  • [2023-08-11 05:12:55]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long

using namespace std;

int z, n, works[105][105];

int gcd(int x, int y) {
	if (x > y) swap(x, y);
	if (x == y) return x;
	if (x == 0) return y;
	return gcd(x, y % x);
}

bool solve(int x, int y) {
	if (x > y) swap(x, y);
	int g = gcd(x, y), c = y, counts = 1;
	if (g == x || g == y) return true;
	while (1) {
		if (c == g) return true;
		if (c <= 0)return false;
		counts++;
		c = counts * x - (counts - 1) * y;
	}
	return false;
}

int bash() {
	int out = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (solve(i, j)) {
				out++;
				works[i][j]++;
			}
		}
	}
	return out;
}

signed main() {
	//n = 2;
	//for (; n <= 100; n++) {
	//	int ans = 0;
	//	for (int r = 1; r <= n; r = n / (n / r) + 1) {
	//		int nr = n / r;
	//		for (int k = 2; k <= nr - 1; k = ((nr - 1) / ((nr - 1) / k)) + 1) {
	//			int pans = ans;
	//			int nx = (nr - 1) / ((nr - 1) / k);
	//			ans += ((nr - 1) / k) * (nx - k + 1);
	//			if (pans > ans) {
	//				cout << "WTF234\n";
	//			}
	//		}
	//	}
	//	for (int k = 2; k <= n; k = n / (n / k) + 1) {
	//		int pans = ans;
	//		int nk = n / k;
	//		int nx = n / (n / k);
	//		ans += nk * (nx - k + 1);
	//		if (pans > ans) {
	//			cout << "12312\n";
	//		}
	//	}
	//	if (ans != bash()) {
	//		cout << n << ' ' << ans << ' ' << bash() << '\n';
	//	}
	//	else {
	//		cout << "working :/'\n";
	//	}
	//}
	//return 0;
	cin >> z;
	while (z--) {
		cin >> n;
		int ans = 0;
		//for (int i = 1; i <= n; i++) {
		//	for (int j = 1; j <= n; j++) {
		//		works[i][j] = 0;
		//	}
		//}
		for (int r = 1; r <= n; r = n / (n / r) + 1) {
			int nr = n / r;
			for (int k = 1; k <= nr - 1; k = ((nr - 1) / ((nr - 1) / k)) + 1) {
				int pans = ans;
				int nx = (nr - 1) / ((nr - 1) / k);
				for (int i = k; i <= nx; i++) {
					for (int p = 2; p <= (nr - 1) / k; p++) {
						works[(i - 1) * p * r + r][i * p * r + r]++;
						if ((i - 1) * p * r + r == 2 && i * p * r + r == 3) {
							int asdf = 1;
						}
					}
				}
				ans += ((nr - 1) / k - 1) * (nx - k + 1);
				if (pans > ans) {
					cout << "WTF234\n";
				}
			}
		}
		for (int k = 2; k <= n; k = n / (n / k) + 1) {
			int pans = ans;
			int nk = n / k;
			int nx = n / (n / k);
			ans += nk * (nx - k + 1);
			for (int i = k; i <= nx; i++) {
				for (int d = 1; d <= nk; d++) {
					works[d * (i - 1)][d * i]++;
				}
			}
			if (pans > ans) {
				cout << "12312\n";
			}
		}
		//bash();
		cout << ans << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3452kb

input:

3
2
5
14

output:

1
9
62

result:

ok 3 lines

Test #2:

score: -100
Runtime Error

input:

3
29107867360
65171672278
41641960535

output:


result: