hdu 5328 Problem Killer 2015多校联合训练赛4 简单题
来源:互联网 发布:映射网络驱动器不成功 编辑:程序博客网 时间:2024/05/22 00:51
Problem Killer
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1281 Accepted Submission(s): 483
Problem Description
You are a "Problem Killer", you want to solve many problems.
Now you haven problems, the i -th problem's difficulty is represented by an integer ai (1≤ai≤109 ).
For some strange reason, you must choose some integerl and r (1≤l≤r≤n ), and solve the problems between the l -th and the r -th, and these problems' difficulties must form an AP (Arithmetic Progression) or a GP (Geometric Progression).
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
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
Input
The first line contains a single integer T , indicating the number of cases.
For each test case, the first line contains a single integern , the second line contains n integers a1,a2,⋯,an .
T≤104,∑n≤106
For each test case, the first line contains a single integer
Output
For each test case, output one line with a single integer, representing the answer.
Sample Input
251 2 3 4 6101 1 1 1 1 1 2 3 4 5
Sample Output
46
Author
XJZX
Source
2015 Multi-University Training Contest 4
求等比或者等差数列中最长的区间的长度。直接贴解题报告了
http://blog.sina.com.cn/s/blog_15139f1a10102vof7.html
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;long long num[1000001];int main(){ int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i = 0;i < n; i++) scanf("%I64d",&num[i]); int ans = min(n,2); int be = 0; for(int i = 2;i < n; i++){ if(num[i] - num[i-1] == num[i-1] - num[i-2]){ } else be = i-1; ans = max(ans,i-be+1); } be = 0; for(int i = 2;i < n; i++){ if(num[i] * num[i-2] == num[i-1] * num[i-1]){ } else be = i - 1; ans = max(ans,i-be+1); } printf("%d\n",ans); } return 0;}
0 0
- hdu 5328 Problem Killer 2015多校联合训练赛4 简单题
- HDU 5328 Problem Killer (2015 Multi-University Training Contest 4 2015多校联合)
- hdu 5349 MZL's simple problem 2015多校联合训练赛#5 简单题
- HDU 2017 多校联合训练赛8 1011 6143 Killer Names 排列组合
- 2015年多校联合训练第四场(Problem Killer)hdu5328
- 2015 HDU 多校联赛 5328 Problem Killer
- hdu 5327 Olympiad 简单题 2015多校联合训练赛
- HDU 5371 Hotaru's problem 2015多校联合训练赛7
- hdu 5373 The shortest problem 2015多校联合训练赛#7 模拟
- hdu 5402 ,Travelling Salesman Problem,2015多校联合训练赛#9
- HDU 5328 Problem Killer(简单DP)
- 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
- 南邮 OJ 1523 Cuckoo Hashing
- 翻转排序
- UI0804_Palette
- java中的观察者模式2
- iOS-C语言和OC部分
- hdu 5328 Problem Killer 2015多校联合训练赛4 简单题
- 南邮 OJ 1524 Optimal Parking
- java Collection 介绍
- vs无法执行添加/移除操作,因为代码元素**是只读的
- 2506Tiling(大数递推)
- java.util.regex.PatternSyntaxeException
- Eclipse插件开发Perspectives篇
- 切换图片
- 南邮 OJ 1528 Nested Dolls