QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621687#9426. Relearn through ReviewzhoudashuaiWA 118ms7680kbC++141.4kb2024-10-08 16:13:522024-10-08 16:13:53

Judging History

你现在查看的是最新测评结果

  • [2024-10-08 16:13:53]
  • 评测
  • 测评结果:WA
  • 用时:118ms
  • 内存:7680kb
  • [2024-10-08 16:13:52]
  • 提交

answer

#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<set> 
#include<stack>
#include<bitset>
#include<unordered_map>
#include<iomanip>
#include<cassert>
#define fi first
#define se second
#define endl '\n'
#define pb push_back
#define ep emplace_back 
#define debug(x) cout<<x<<'\n'
#define RES cout<<res<<'\n'
#define ANS cout<<ans<<'\n'
#define YES	cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes	cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define me(a,x) memset(a,x,sizeof(a))
#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define r23 cout<<233<<endl;return;
#define int long long 
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;
typedef unsigned long long ull;
const int N=3e5+5,P=131,mod=998244353;
int n,k;
int a[N],pre[N],suf[N]; 

void solve(){
	cin>>n>>k;
	L(i,1,n)cin>>a[i];
	int g=0;
	L(i,1,n)pre[i]=g=__gcd(g,a[i]);
	g=0;
	R(i,n,1)suf[i]=g=__gcd(g,a[i]);
	int res=pre[n];
	L(i,0,n-1){
		if(pre[i]!=pre[i+1]){
			int cur=pre[i];
			L(j,i+1,n){
				cur=__gcd(cur,a[j]+k);
				res=max(res,__gcd(cur,suf[j+1]));
			}	
		}
	}
	RES;
}
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T=1;
	cin>>T;
	while(T--){
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 7680kb

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: 118ms
memory: 7680kb

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
3
1
98423435849394582
183698346865682381
3
484915690810412536
6
149180825015886938
361813583202892479
915781395066183375
37337367838628559
632093288650732211
377121713907330928
2
494408344393555851
2
2
118387461231999184
1
383091938972089281
1...

result:

wrong answer 4th lines differ - expected: '182894211060271407', found: '3'