QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#799563 | #9426. Relearn through Review | fsy_juruo | WA | 100ms | 9836kb | C++17 | 876b | 2024-12-05 15:52:56 | 2024-12-05 15:52:58 |
Judging History
answer
#include <bits/stdc++.h>
using LL = long long;
const int maxN = 3e5 + 10;
int T, n;
LL k, a[maxN], pre[maxN], suf[maxN], d[maxN];
int main() {
std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
std::cin >> T;
while(T--) {
std::cin >> n >> k;
for(int i = 1; i <= n; i++) {
std::cin >> a[i];
d[i] = a[i] - a[i - 1];
}
pre[1] = a[1];
suf[n] = a[n];
for(int i = 2; i <= n; i++) {
pre[i] = std::__gcd(pre[i - 1], a[i]);
}
for(int i = n - 1; i >= 1; i--) {
suf[i] = std::__gcd(suf[i + 1], a[i]);
}
LL ans = pre[n];
for(int i = 1; i < n; i++) {
if(pre[i] != pre[i + 1]) {
int l = i;
LL g = pre[i];
for(int j = i + 1; j <= n; j++) {
LL h = std::__gcd(g, a[j] + k);
ans = std::max(ans, std::__gcd(h, suf[j + 1]));
}
}
}
std::cout << ans << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 9836kb
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: 100ms
memory: 9816kb
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 3 1 98423435849394582 1 3 484915690810412536 3 149180825015886938 361813583202892479 915781395066183375 821422092449828298 632093288650732211 1 2 494408344393555851 1 1 118387461231999184 1 766183877944178562 1 809535299113892268 5807871858756740...
result:
wrong answer 1st lines differ - expected: '641766957852455745', found: '33155506392034032'