现在在队内赛(灰常艾斯比的队内赛),还是来写篇题解开心一下,23333.

题意:

就是问你找出一个最长的等比数列或者等差数列

思路:

一个等差的尺取,一个等比的尺取。2333,就这么过了,具体自己写吧。还是很容易实现的,注意数组要开1e6…还有long long….后面要做乘法。

#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;
typedef __int64 LL; const int N=1e6+10; LL a[N];
int n; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]); if(n==1)
{
puts("1");
continue;
} int sum1;
int sum2,temp;
int s,t;
LL x1,x2; temp=1;
sum1=1;
t=2;
for(s=1;s<n;s++)
{
x1=a[t]-a[s];
while(x1==(a[t+1]-a[t])&&t+1<=n)
{
temp=t-s+2;
t++;
}
s=t-1;
t=t+1;
sum1=max(sum1,temp);
} temp=sum2=2;
t=2;
for(s=1;s<n;s++)
{
while((a[t+1]*a[t-1])==(a[t]*a[t])&&t+1<=n)
{
temp=t-s+2;
t++;
}
s=t-1;
t=t+1;
sum2=max(sum2,temp);
}
printf("%d\n",max(sum1,sum2));
}
}
/*
10
1 2 3 4 6 8 10 12 14 16
13
1 2 3 4 6 1 3 1 8 10 12 14 16
*/

hdoj5328【尺取】的更多相关文章

  1. Gym 100703I---Endeavor for perfection(尺取)

    题目链接 http://codeforces.com/problemset/gymProblem/100703/I Description standard input/outputStatement ...

  2. NOJ 1072 The longest same color grid(尺取)

    Problem 1072: The longest same color grid Time Limits:  1000 MS   Memory Limits:  65536 KB 64-bit in ...

  3. hdu 4123 Bob’s Race 树的直径+rmq+尺取

    Bob’s Race Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Probl ...

  4. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) E. Cubes (尺取)

    题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序 ...

  5. poj2566尺取变形

    Signals of most probably extra-terrestrial origin have been received and digitalized by The Aeronaut ...

  6. poj2100还是尺取

    King George has recently decided that he would like to have a new design for the royal graveyard. Th ...

  7. hdu 6231 -- K-th Number(二分+尺取)

    题目链接 Problem Description Alice are given an array A[1..N] with N numbers. Now Alice want to build an ...

  8. Codeforces 939E Maximize! (三分 || 尺取)

    <题目链接> 题目大意:给定一段序列,每次进行两次操作,输入1 x代表插入x元素(x元素一定大于等于之前的所有元素),或者输入2,表示输出这个序列的任意子集$s$,使得$max(s)-me ...

  9. cf1121d 尺取

    尺取,写起来有点麻烦 枚举左端点,然后找到右端点,,使得区间[l,r]里各种颜色花朵的数量满足b数组中各种花朵的数量,然后再judge区间[l,r]截取出后能否可以供剩下的n-1个人做花环 /* 给定 ...

随机推荐

  1. SolidEdge 工程图中如何控制是否显示爆炸图组装线

    右击视图,点击性质,取消勾选"显示流线"   即可取消爆炸视图的装配线              

  2. hdu 1710 Binary Tree Traversals 前序遍历和中序推后序

    题链;http://acm.hdu.edu.cn/showproblem.php?pid=1710 Binary Tree Traversals Time Limit: 1000/1000 MS (J ...

  3. Intel processor brand names-Xeon,Core,Pentium,Celeron----Pentium

    http://en.wikipedia.org/wiki/Pentium Pentium From Wikipedia, the free encyclopedia     This article ...

  4. FragmentSharedFabTransition

    https://github.com/lgvalle/FragmentSharedFabTransition

  5. hiho1079 线段树区间改动离散化

    题目链接: hihocoder1079 代码: #include<iostream> #include<cstdio> #include<cstring> #inc ...

  6. Arcgis Engine(ae)接口详解(8):临时元素(element)

    //主地图的地图(map)对象 IMap map = null; IActiveView activeView = null; //IGraphicsContainer用于操作临时元素,可以通过map ...

  7. Android的onMeasure方法

    在Android开发中,当Android原生控件不能满足我们的需求的时候,就需要自定义View.View在屏幕上绘制出来先要经过measure(计算)和layout(布局). 什么时候调用onMeas ...

  8. Spring Batch(4): Job具体解释

    第四章 配置作业Job 4.1 基本配置 Job的配置有3个必须的属性.name,jobRepository,steps.一个简单的Job配置例如以下: <job id="footba ...

  9. Vs2012在Linux开发中的应用(6):改写Makefile项目的Build过程

    MSBUILD的编译过程实际上是依据一系列的targets文件定义的.当我们在IDE运行生成.批生成.清理命令的时候.VS会查找这些命令相应的Task并运行它,以下我们逐个分析这个过程. 当运行生成操 ...

  10. app上架的照片尺寸大小