http://acm.hzau.edu.cn/problem.php?id=21

题目大意: 给你一个序列问在数字最多的等比数列

分析:  刚开始看到题就知道是一个dp但是我dp实在是渣到不行

后来发现用二维dp  第二位保存i到j的差

#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <stack>
#include <algorithm>
using namespace std;
#define N 2050
#define memset(a,b) memset(a,b,sizeof(a)) int dp[N][N]; int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
dp[i][j]=;
}
}
int a[N];
memset(a,);
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
int Max=;
for(int i=;i<n;i++)
{
for(int j=;j<i;j++)
{
int d=a[i]-a[j];
dp[i][d]=dp[j][d]+;
Max=max(Max,dp[i][d]);
}
}
printf("%d\n",Max);
}
return ;
}

21: Arithmetic Sequence--HZAU(dp)的更多相关文章

  1. HZAU 21——Arithmetic Sequence——————【暴力 or dp】

    Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1810  Solved: 311[Submit][Status] ...

  2. Arithmetic Sequence(dp)

    Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 51  Solved: 19[Submit][Status][We ...

  3. hdu 5400 Arithmetic Sequence(模拟)

    Problem Description A sequence b1,b2,⋯,bn are called (d1,d2)-arithmetic sequence ≤i≤n) such that ≤j& ...

  4. [Swift]LeetCode1027. 最长等差数列 | Longest Arithmetic Sequence

    Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall t ...

  5. (模拟)Arithmetic Sequence -- HDU -- 5400

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=5400 Time Limit: 4000/2000 MS (Java/Others)    Memory ...

  6. LeetCode 1027. Longest Arithmetic Sequence

    原题链接在这里:https://leetcode.com/problems/longest-arithmetic-sequence/ 题目: Given an array A of integers, ...

  7. hdu 5400 Arithmetic Sequence

    http://acm.hdu.edu.cn/showproblem.php?pid=5400 Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Ot ...

  8. 华中农业大学第四届程序设计大赛网络同步赛-1020: Arithmetic Sequence,题挺好的,考思路;

    1020: Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MB Submit:  ->打开链接<- Descriptio ...

  9. 【leetcode】1027. Longest Arithmetic Sequence

    题目如下: Given an array A of integers, return the length of the longest arithmetic subsequence in A. Re ...

  10. Arithmetic Sequence

    Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

随机推荐

  1. php操作文件及下载图片脚本

    <?php set_time_limit(0); $handle = fopen('article.txt','r'); for($i=0;$i<1;$i++) { $count = 0; ...

  2. 如何删除控制文件中过去rman备份到磁带的备份集

    问题描述: 早上做数据库巡检,发现FRA(flash recovery area)空间使用率达到66%,是平时的两倍.由于库不大,备份策略是本地磁盘备份,每天一全备,REDUNDANCY 1 ,备份完 ...

  3. Ping 命令的使用方法总结

    一.Ping 命令 “Ping”命令是我们在判断网络故障常用的命令,但您真正明白这个命令运行后会发生什么,以及出现的各种信息说明了什么吗?其实熟练的掌握 Ping 命令的各种技巧可以帮助你解决很多网络 ...

  4. log4j按级别输出日志文件

    log4j.properties: BASE_DIR= /home/admin/preprocess-tmc-city/logs log4j.rootLogger=debug,stdout,debug ...

  5. C#(Winform) Http 发送数据

    Get方式 private string HttpGet(string url, string postData) { HttpWebRequest request = (HttpWebRequest ...

  6. JSP、HTML标签

    <%@ ...%> 表示是指令,主要用来提供整个JSP 网页相关的信息,并且用来设定JSP网页的相关属性,例如:网页的编码方式.语法.信息等.起始符号为: <%@ 终止符号为: %& ...

  7. 2016-06-06:X264码率控制

    H.264与x264 H264是一个视频压缩编码标准.https://zh.wikipedia.org/wiki/H.264/MPEG-4_AVC X264实现H264视频压缩标准的开源项目.http ...

  8. Linux 相关基础笔记

    html,body { } .CodeMirror { height: auto } .CodeMirror-scroll { } .CodeMirror-lines { padding: 4px 0 ...

  9. c++的类与对象

    对象:此对象,非彼对象,:-D,跟妹子无关(不过貌似也可以,,),闲言少叙,书归正传 我们可以把我们见到的一切事物都称为对象.它可以有形,可以无形,可以简单,可以复杂,但是对某一种具体的对象,比如公司 ...

  10. JS --正则表达式验证、实战之邮箱模式

     JS验证格式:提高用户体验,验证文本. 需要防止程序员的代码结构更改攻击,因为web段的代码有可能会被更改,更改后JS有可能会验证不住那么,C#端在JS段通过验证的情况下,还需要进行二次验证 < ...