HDU 5328 Problem Killer(水题)】的更多相关文章

题意: 给一个序列,要找一个等差或等比的连续子序列,求其最长的长度. 思路: 扫两遍,判断等差或等比即可.从左往右扫,维护一个滑动窗口,考虑新加进来的数,如果满足了要求,则更新长度,否则只留最后两个数字,其他删掉,接着继续考虑下一个数字.等比也是如此,只是要注意精度的问题. 别人的代码: #include <bits/stdc++.h> using namespace std; ; int arr[MAX]; int main(void) { //freopen("in.txt&qu…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5328 题目大意:找到连续的最长的等差数列or等比数列. 解题思路:1.等差等比的性质有很多.其中比较重要的一个就是解题关键:如a[i-2],a[i-1],a[i],a[i+1]这个序列.a[i-2],a[i-1],a[i]是等差数列,a[i-1],a[i],a[i+1]也是等差数列.那么a[i-2],a[i-1],a[i],a[i+1]就是等差数列.  2. 等比数列也是一样的~~只要根据这个性质就…
题意:给一段序列,求连续的子序列中最长的等差数列或者等比数列的长度. 解法:O(n)的扫两遍一次判等差一次判等比就好了. 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include<string> #include<string.h> #include<math.h> #include<limits.h> #include<time.h&…
http://acm.fzu.edu.cn/problem.php?pid=2182 Problem 2182 水题 Accept: 188    Submit: 277Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description 胖哥自从当上公务员,赢取白富美,走向人生巅峰后,已经懒散到不想出题了,不仅如此,他连题目都懒得看了,现在他只会根据题目第一个单词的长度判定这个题目的难度 如果题目的第一个单词太长(长度大于3…
题目传送门 /* 递推DP: 如果a, b, c是等差数列,且b, c, d是等差数列,那么a, b, c, d是等差数列,等比数列同理 判断ai-2, ai-1, ai是否是等差(比)数列,能在O(n)时间求出最长的长度 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll…
Problem A: The 3n + 1 problem Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 14  Solved: 6[Submit][Status][Web Board] Description Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2. I…
排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30009    Accepted Submission(s): 8326 Problem Description 输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若…
Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a kingdom. A monster has invaded this kingdom, and Teacher Mai wants to kill it. Monster initially has h HP. And it will die if HP is less than 1. Teache…
Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=95149#problem/A Description Some strange code is sent to Da Shan High School. It's said to be the prophet's note. The note is extremely hard t…
H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87326#problem/H Description A robot is a mechanical or virtual artificial agent, usually an electro-mechanical machine that is guided by a com…