hdoj 5328 Problems killer
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5328
#include<stdio.h>
#include<algorithm>
typedef long long ll;
;
ll a[MAXN];
int main()
{
int lgt; int T;
int n; int tmp;
int i;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
; i < n; ++i){
scanf("%I64d",&a[i]);
}
){
printf("2\n");
continue;
}
){
printf("1\n");
continue;
}
lgt = ;
tmp = ;
; i < n; ++i){
] ) == ( a[i-] - a[i-] ) ){
tmp++;
lgt = std::max(tmp,lgt);
}
else{
lgt = std::max(tmp,lgt);
tmp = ;
}
}
tmp = ;
; i < n; ++i){
] ) == ( (] / (] ) ){
tmp++;
lgt = std::max(tmp,lgt);
}
else{
lgt = std::max(tmp,lgt);
tmp = ;
}
}
printf("%d\n",lgt);
}
}
hdoj 5328 Problems killer的更多相关文章
- 递推DP HDOJ 5328 Problem Killer
题目传送门 /* 递推DP: 如果a, b, c是等差数列,且b, c, d是等差数列,那么a, b, c, d是等差数列,等比数列同理 判断ai-2, ai-1, ai是否是等差(比)数列,能在O( ...
- hdu 5328 Problem Killer(杭电多校赛第四场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5328 题目大意:找到连续的最长的等差数列or等比数列. 解题思路:1.等差等比的性质有很多.其中比较重 ...
- HDU 5328 Problem Killer(水题)
题意: 给一个序列,要找一个等差或等比的连续子序列,求其最长的长度. 思路: 扫两遍,判断等差或等比即可.从左往右扫,维护一个滑动窗口,考虑新加进来的数,如果满足了要求,则更新长度,否则只留最后两个数 ...
- HDU 5328 Problem Killer
题意:给一段序列,求连续的子序列中最长的等差数列或者等比数列的长度. 解法:O(n)的扫两遍一次判等差一次判等比就好了. 代码: #include<stdio.h> #include< ...
- HDOJ Sudoku Killer(dfs)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1426 思路分析:该问题为数独问题,明显解是唯一的,所有采用dfs搜索效果更好: 在搜索时,可以通过3个 ...
- 25 Killer Actions to Boost Your Self-Confidence
25 Killer Actions to Boost Your Self-Confidence Once we believe in ourselves, we can risk curiosity, ...
- 2015暑假多校联合---Problem Killer(暴力)
原题链接 Problem Description You are a "Problem Killer", you want to solve many problems. Now ...
- 【HDOJ】【3068】最长回文
Manacher算法 Manacher模板题…… //HDOJ 3068 #include<cstdio> #include<cstring> #include<cstd ...
- 算法——A*——HDOJ:1813
Escape from Tetris Time Limit: 12000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
随机推荐
- appserver配置虚拟主机
1, apach配置文件开启虚拟主机服务(C:\AppServ\Apache2.2\conf\httpd.conf)大概561行的位置 # Virtual hostsInclude conf/extr ...
- 安装完eclipse,dbwear后,需要在他们解压文件.ini下加上你liux的jdk的安装路径,才能正常使用
-vm/usr/java/jdk/jdk1.6.0_45/bin/java
- JVM——垃圾收集器
概念补充 并行(Parallel):指多条垃圾收集线程并行工作,但此时用户线程仍然处于等待状态. 并发(Concurrent):指用户线程与垃圾收集线程同时执行(但不一定是并行的,可能会交替执行),用 ...
- Word2003使用VBA教程
[正文] 注:本文中所有vba代码都是储存在doc中,而非normal.dot 1.打开一个.doc文档 2.按ALT+F11 3.左侧 Project-插入-模块 4.输入自己的代码,一定要是函数的 ...
- Spring工厂方式创建Bean实例
创建Bean实例的方式: 1) 通过构造器(有参或无参) 方式: <bean id="" class=""/> 2) 通过静态工厂方法 方式: &l ...
- 字符串中符号的替换---replace的用法
#include<iostream> #include<string> using namespace std; int main() { string s1 = " ...
- HP Web Tours分析
1.启动Web Tours 2.首页结构 3.预定机票
- windows10UWP开发真机调试时遇到DEP6100和DEP6200解决办法
windows10UWP开发真机调试时遇到DEP6100和DEP6200(其实未连接上设备都会报这两个错误,无论真机还是虚拟机)…… 此方法适合真机调试时遇到: 弹出提示框要求输入配对码,无论如何输入 ...
- c/c++ 数字转成字符串, 字符串转成数字
c/c++ 数字转成字符串, 字符串转成数字 ------转帖 数字转字符串: 用C++的streanstream: #include <sstream> #Include <str ...
- Cracking the Code Interview 4.3 Array to Binary Tree
Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal hei ...