QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627727#9426. Relearn through Reviewshiqiaqiaya#WA 102ms3560kbC++20932b2024-10-10 16:56:522024-10-10 16:56:53

Judging History

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

  • [2024-10-10 16:56:53]
  • 评测
  • 测评结果:WA
  • 用时:102ms
  • 内存:3560kb
  • [2024-10-10 16:56:52]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;

	vector<int> a(n + 1), b(n + 1);

	int d = 0;
	vector<int> p;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = a[i] - a[i - 1];
		if (i > 1 && d > gcd(d, b[i])) {
			p.push_back(i);
		}
		d = gcd(d, b[i]);
	}
	int ans = d;

	for (int u : p) {
		vector<int> p1;
		b[u] += k;
		int d = 0;
		for (int i = 1; i <= n; i++) {
			if (i > u && d > gcd(d, b[i])) {
				p1.push_back(i);
			}
			d = gcd(d, b[i]);
		}
		ans = max(ans, d);
		for (int v : p1) {
			b[v] -= k;
			int d = 0;
			for (int i = 1; i <= n; i++) {
				d = gcd(d, b[i]);
			}
			ans = max(ans, d);
			b[v] += k;
		}
		b[u] -= k;
	}

	cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T;
    cin >> T;
    while (T--) solve();

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

2
6 2
5 3 13 8 10 555
3 0
3 6 9

output:

5
3

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 102ms
memory: 3560kb

input:

100000
1 608611451460421713
33155506392034032
1 743116173559300609
6138108577573005
7 364454564010802125
657035115675878115 657035115675878115 657035115675878115 657035115675878115 657035115675878115 292580551665075990 657035115675878115
4 316648374341335221
365788422120542814 182894211060271407 731...

output:

33155506392034032
6138108577573005
657035115675878115
182894211060271407
880411769063535667
98423435849394582
1
962990836390050009
484915690810412536
878097339332572161
149180825015886938
361813583202892479
915781395066183375
37337367838628559
632093288650732211
1
2
494408344393555851
56610464278188...

result:

wrong answer 1st lines differ - expected: '641766957852455745', found: '33155506392034032'