HDU 5328 Problem Killer
来源:互联网 发布:unity3d itween下载 编辑:程序博客网 时间:2024/05/10 22:53
Problem Killer
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 252 Accepted Submission(s): 97
Now you have
For some strange reason, you must choose some integer
So how many problems can you solve at most?
You can find the definitions of AP and GP by the following links:
https://en.wikipedia.org/wiki/Arithmetic_progression
https://en.wikipedia.org/wiki/Geometric_progression
For each test case, the first line contains a single integer
251 2 3 4 6101 1 1 1 1 1 2 3 4 5
46
/* ***********************************************
Author :
Created Time :2015/7/30 13:57:52
File Name :2.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1000000000
#define maxn 1000000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int n;
int a[maxn];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int t;
cin>>t;
while(t--){
scanf("%d",&n);
int d=-INF-INF-10;
double q=0.0;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
int Max=1;
int MMax=1;
int x=1,y=1;
for(int i=2;i<=n;i++){
int d1=a[i]-a[i-1];
if(d1==d){
x++;
if(x>Max){
Max=x;
}
}
else {
d=d1;
x=1;
}
}
for(int i=2;i<=n;i++){
double q1=a[i]*1.0/(a[i-1]*1.0);
if(q1==q){
y++;
if(y>MMax){
MMax=y;
}
}
else{
q=q1;
y=1;
}
}
if(n==1)printf("%d\n",1);
else printf("%d\n",max(Max,MMax)+1);
}
return 0;
}
- HDU 5328 Problem Killer
- HDU 5328 Problem Killer
- hdu 5328 Problem Killer
- hdu 5328 Problem Killer
- HDU 5328 Problem Killer
- HDU 5328 Problem Killer
- Hdu-5328 Problem Killer
- HDU 5328 Problem Killer
- HDU 5328 Problem Killer
- HDU 5328(Problem Killer-暴力)
- hdu 5328 Problem Killer(水题)
- hdu 5328 Problem Killer (水)
- HDU 5328 Problem Killer(简单DP)
- Hdu 5328 Problem Killer (尺取)
- HDU 5238 Problem Killer
- 【HDOJ 5328】 Problem Killer
- 2015 HDU 多校联赛 5328 Problem Killer
- HDU 5328(2015多校4)-Problem Killer(水题)
- Python 高亮设置(转)
- 记录统计编程的插件 wakatime
- BestCoder Round #47 ($) HDU 5280 Senior\'s Array
- HDU 5326 Work
- HBase笔记:Region拆分策略
- HDU 5328 Problem Killer
- HDU 5319 Painter
- POJ 3254 Corn Fields
- HDU 5339 Untitled
- POJ 1185 炮兵阵地
- android camera 通过onPreviewFrame采集视频
- POJ 2411 Mondriaan\'s Dream
- POJ 3273 Monthly Expense
- HDU 5360 Hiking