QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#656483 | #9426. Relearn through Review | zzuqy | WA | 132ms | 5920kb | C++14 | 1.7kb | 2024-10-19 13:10:57 | 2024-10-19 13:10:58 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define db double
#define INF 1100000000
#define inf 100000000000000000ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x)
#define putl_(x) printf("%lld ",x)
#define get(x) x=read()
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(int i=p;i<=n;i+=1)
#define fep(n,p,i) for(int i=n;i>=p;--i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define pii pair<int,int>
#define mk make_pair
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ui unsigned
#define sq sqrt
#define l(w) t[w].l
#define r(w) t[w].r
#define x(w) t[w].x
#define tag(w) t[w].tag
#define sum(w) t[w].sum
#define sc(A) scanf("%d",&A)
#define scl(A) scanf("%lld",&A)
#define scs(A) scanf("%s",A);
#define put(A) printf("%d\n",A)
#define min(x,y) (x>=y?y:x)
#define max(x,y) (x>=y?x:y)
#define sub(x,y) (x-y<0?x-y+mod:x-y)
#define uint unsigned int
#define mod 1000000007
#define zz p<<1
using namespace std;
const int MAXN=300010,N=2000010;
int n;
ll k;
ll a[MAXN];
int T;
map<ll,int>H;
ll f[MAXN];
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
void work()
{
sc(n);scl(k);
rep(1,n,i)scl(a[i]);
f[n+1]=0;
fep(n,1,i)
{
f[i]=gcd(f[i+1],a[i]);
}
ll c=0;
H.clear();
H[0]=0;
rep(1,n,i)
{
c=gcd(c,a[i]);
H[c]=i;
}
ll ans=0;
for(auto x:H)
{
//cout<<x.first<<endl;
int l=x.second;
int las=0;
rep(l+1,n,r)
{
ll res=x.first;
res=gcd(res,las);
res=gcd(res,f[r+1]);
res=gcd(res,a[r]+k);
ans=max(ans,res);
las=gcd(las,abs(a[r+1]-a[r]));
}
}
putl(ans);
}
int main()
{
sc(T);
while(T--)
{
work();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5896kb
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: 132ms
memory: 5920kb
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 182894211060271407 880411769063535667 560553564512176618 1 962990836390050009 616597869896951268 878097339332572161 188820994675344528 997057718507559252 949074379610491450 33 632093288650732211 377121713907330928 2 789177332497135009 56610464...
result:
wrong answer 7th lines differ - expected: '183698346865682381', found: '1'