QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#797262 | #9426. Relearn through Review | lengli | WA | 131ms | 3800kb | C++23 | 978b | 2024-12-02 19:57:34 | 2024-12-02 19:57:35 |
Judging History
answer
/*
lengli_QAQ
Hope there are no bugs!!!
*/
#include <bits/stdc++.h>
#define fastio std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define all(x) x.begin(),x.end()
#define pb push_back
#define i64 long long
void solve(){
i64 n,k;
std::cin>>n>>k;
std::vector<i64> a(n+2),pre(n+2,0),suf(n+2,0);
for(int i=1;i<=n;i++) std::cin>>a[i];
for(int i=1;i<=n;i++) pre[i]=std::gcd(pre[i-1],a[i]);
for(int i=n;i>=1;i--) suf[i]=std::gcd(suf[i+1],a[i]);
i64 res=pre[n];
i64 la=0;
for(int i=1;i<=n;i++){
if(pre[i]==pre[i-1]) continue;
i64 d=a[i]+k;
for(int j=i;j<=n;j++){
d=std::gcd(d,a[j]+k);
i64 ans=std::gcd(pre[i-1],d);
ans=std::gcd(suf[j+1],d);
res=std::max(res,ans);
}
}
std::cout<<res<<"\n";
}
signed main(){
fastio;
int T;
std::cin>>T;
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3800kb
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: 131ms
memory: 3568kb
input:
100000 1 608611451460421713 33155506392034032 1 743116173559300609 6138108577573005 7 364454564010802125 657035115675878115 657035115675878115 657035115675878115 657035115675878115 657035115675878115 292580551665075990 657035115675878115 4 316648374341335221 365788422120542814 182894211060271407 731...
output:
641766957852455745 749254282136873614 657035115675878115 731576844241085628 880411769063535667 560553564512176618 183698346865682381 962990836390050009 616597869896951268 878097339332572161 188820994675344528 997057718507559252 949074379610491450 821422092449828298 632093288650732211 867398114659890...
result:
wrong answer 4th lines differ - expected: '182894211060271407', found: '731576844241085628'