Title Address: HDU 5328
Test instructions: In a sequence of length n to remove the number of consecutive k, so that the number of k composition arithmetic progression or geometric series, ask such k maximum can be how much.
Ps: Pay attention to double, because the geometric series divide may be decimal.
#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#pragma COMMENT (linker, "/stack:102400000,102400000")using namespace STD;typedef Long LongLL;Const intinf=0x3f3f3f3f;Const DoublePi=ACOs(-1.0);Const Doubleesp=1e-6;Const intmaxn=1e6+Ten;DoubleA[MAXN];intMain () {intT,n,i;DoubleD,q;intAnsintL,r;scanf("%d", &t); while(t--) {scanf("%d", &n); for(i=0; i<n;i++)scanf("%LF", &a[i]);if(n==1){puts("1");Continue; } d=a[1]-a[0]; q=a[1]/a[0]; l=r=ans=2; for(i=2; i<n;i++) {if(a[i]-a[i-1]==d) l++;Else{d=a[i]-a[i-1]; Ans=max (ans,l); L=2; }if(a[i]/a[i-1]==Q) r++;Else{q=a[i]/a[i-1]; Ans=max (ANS,R); R=2; }} Ans=max (Ans,max (l,r));printf("%d\n", ans); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 5328 (more than 2015 schools 4)-problem Killer (water problem)