Multi-School # #

Source: Internet
Author: User

1001, HDU 5327 Olympiad

Play a table check-in question. The degree of opening 4minFB ...

There should be a more optimized method, in order to hand speed without tle on the line ... = =

1002, HDU 5328 zzx and permutations

AP: Linear sequence

GP: equal-ratio sequence

The length of the maximum sequence of AP and GP is calculated by the ruler, then the maximal value can be obtained.

It is important to note that the equivalence is best used in a proportional way rather than in division, because the sample, like [9 6 4], produces a precision problem, and if you use 9*4==6*6 it will not be a problem. Of course, the resulting problem is that multiplying the words can cause an int overflow, so a long long is required to save a array.

Outputs 1 or 2 when an AP or GP sequence cannot form three elements;

#include <cstdio>#include<cstring>#include<iostream>#include<iostream>#include<cmath>#include<algorithm>using namespaceStd;typedefLong Longll;Const intMAXN =1000010; ll A[MAXN];intN;intAP () {intRET =2; intT1, T2, T3, S; S= T1 =0; T2=1; T3=2;  while(1)    {         while(T3 < n && a[t3]-a[t2] = = a[t2]-A[t1]) {T1+ +, t2++, t3++; }        if(T3 >=N) {ret= Max (ret, t3-s);  Break; } ret= Max (ret, t3-s); S=T2; T1++; t2++; t3++; }    returnret;}intGP ()//here Direct copy AP () Change a little condition can{    intRET =2; intT1, T2, T3, S; S= T1 =0; T2=1; T3=2;  while(1)    {        //cout << a[t2] << "<< a[t3] <<" "<< a[t1] << Endl;         while(T3 < n && a[t2]*a[t2] = = a[t3]*A[t1]) {T1+ +, t2++, t3++; }        if(T3 >=N) {ret= Max (ret, t3-s);  Break; } ret= Max (ret, t3-s); S=T2; T1++; t2++; t3++; }    returnret;}intMain () {intT scanf"%d", &T);  while(t--) {scanf ("%d", &N);  for(inti =0; I < n; i++) scanf ("%lld", &A[i]); if(n = =1|| n = =2) {cout<< N <<Endl; Continue; }        intAPs, GP; AP=AP (); GP=GP (); cout<< Max (APS, GP) <<Endl; }    return 0;}

Cond...

Multi-School # #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.