|
|
back to boardhelp ??? WA #4 #include<iostream> #include<cstdlib> #include<cstdio> #include<cmath> long a[100000]; long b[100000]; long c[100000]; int d[100000]; using namespace std; int main(){ int n; int max; cin>>n; int i; for (i=0; i<n; i++){ cin>>a[i]; d[i]=1; } for (i=0; i<n-1; i++){ float r=1+(a[i+1]-a[i])*(a[i+1]-a[i]); c[i]=sqrt(r);
} for (i=0; i<n-2; i++){ if ((a[i]-a[i+1])==(a[i+1]-a[i+2])){ c[i+1]+=c[i]; d[i+1]=d[i]+1; //cout<<d[i]<<" "; } } max=c[0]; int t=0; for (i=0; i<n-1; i++){ if (max<c[i]) { max=c[i]; t=i; } } // cout<<d[0]<<" "<<d[1]<<" "<<d[2]<<" "<<d[3]<<" "; cout<<t+2-d[t]<<" "<<t+2; system("pause"); } |
|
|