QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618725 | #9426. Relearn through Review | rotcar07 | WA | 96ms | 7736kb | C++20 | 709b | 2024-10-07 09:01:18 | 2024-10-07 09:01:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int maxn=3e5+5;
int n;ll k,a[maxn],pre[maxn],suf[maxn];
inline void solve(){
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i];
ll g=0;
for(int i=1;i<=n;i++) pre[i]=g=gcd(g,a[i]);
suf[n+1]=0;g=0;
for(int i=n;i>=1;i--) suf[i]=g=gcd(g,a[i]);
ll ans=pre[n];
for(int i=1;i<n;i++)if(pre[i]!=pre[i+1]){
ll cur=pre[i];
for(int j=i+1;j<=n;j++){
cur=gcd(cur,a[j]+k);
ans=max(ans,gcd(cur,suf[j+1]));
}
}
cout<<ans<<'\n';
}
int main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7736kb
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: 96ms
memory: 7684kb
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'