QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#698182#9426. Relearn through ReviewSpinozaWA 12ms3804kbC++20860b2024-11-01 18:00:482024-11-01 18:00:50

Judging History

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

  • [2024-11-01 18:00:50]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:3804kb
  • [2024-11-01 18:00:48]
  • 提交

answer

#include<bits/stdc++.h>
const int P = 998244353;
typedef long long ll;
#define rep(i,x,y) for (int i=(x);i<=(y);++i)
using namespace std;
void solve() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n + 1);
	vector<int>last(n + 2);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int en = 0;
	for (int i = n; i >= 1; i--) {
		last[i] = __gcd(a[i], en);
		en = last[i];
	}
	int g = 0;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (g != __gcd(g, a[i])) {
			int cntg = 0;
			for (int j = i; j <= n; j++) {
				cntg = __gcd(cntg, a[j] + k);
				ans = max(ans, __gcd(__gcd(cntg, g), last[j + 1]));
			}
		}
		g=__gcd(g,a[i]);
	}
	cout << ans << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	cin >> t;
	while (t--) solve();
	return 0;
}
/*
2
6 2
5 3 13 8 10 555
3 0
3 6 9
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 12ms
memory: 3804kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

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