QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#640626 | #9426. Relearn through Review | Cu_OH_2 | WA | 94ms | 3552kb | C++20 | 1.1kb | 2024-10-14 14:52:21 | 2024-10-14 14:52:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
ll n, k;
cin >> n >> k;
vector<ll> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
set<ll> s;
ll g = 0;
for (int i = 0; i < n; ++i)
{
g = __gcd(g, a[i]);
s.insert(g);
}
g = 0;
for (int i = n - 1; i >= 0; --i)
{
g = __gcd(g, a[i]);
s.insert(g);
}
ll ans = 1;
for (auto e : s)
{
vector<int> v;
vector<ll> t(a);
bool f = 1;
for (int i = 0; i < n; ++i)
{
if (a[i] % e && (a[i] + k) % e == 0) v.push_back(i);
}
if (v.size())
{
int lef = *min_element(v.begin(), v.end());
int rig = *max_element(v.begin(), v.end());
for (int i = lef; i <= rig; ++i) t[i] += k;
}
for (int i = 0; i < n; ++i)
{
if (t[i] % e) f = 0;
}
if (f) ans = e;
}
cout << ans << '\n';
return;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3472kb
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: 94ms
memory: 3552kb
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 2 632093288650732211 1 2 494408344393555851 566104642781888753 41484978512...
result:
wrong answer 1st lines differ - expected: '641766957852455745', found: '33155506392034032'