AcWing 3311. 最长算术
原题链接
简单
作者:
phanhom
,
2022-06-27 11:08:32
,
所有人可见
,
阅读 165
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2e5 +10;
int main(){
int t;
scanf("%d", &t);
for (int i = 1; i <= t; i ++ ){
int a[N],x,ans=2,temp,last;
scanf("%d", &x);
for(int j =0 ; j < x ; j ++ ){
scanf("%d",&temp);
if(j) a[j-1]=temp-last;
last = temp;
}
temp=2;
for(int j=0;j<x-2;j++){
if(a[j]==a[j+1])temp++;
else temp =2;
ans = max(ans,temp);
}
printf("Case #%d: %d\n",i,ans);
}
}