博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
bzoj 3357: [Usaco2004]等差数列
阅读量:4680 次
发布时间:2019-06-09

本文共 608 字,大约阅读时间需要 2 分钟。

3357: [Usaco2004]等差数列

Time Limit: 10 Sec  Memory Limit: 128 MB

Description

    约翰发现奶牛经常排成等差数列的号码.他看到五头牛排成这样的序号:“1,4,3,5,7”
很容易看出“1,3,5,7”是等差数列.
    给出N(1≤N≤2000)数字AI..AN(O≤Ai≤10^9),找出最长的等差数列,输出长度.

Input

    第1行:一个整数N.
    第2到N+1行:每行一个整数Ai,表示牛的号码.

Output

 
    最长等差数列的长度.

Sample Input

5
1
4
3
5
7

Sample Output

4

HINT

 

#include#include
#define M 2020using namespace std;int n,ans,a[M];map
f[M];int main(){ int i,j; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); if(n==1)printf("1"); else{ for(i=1;i<=n;i++) for(j=1;j

 

转载于:https://www.cnblogs.com/lkhll/p/6097126.html

你可能感兴趣的文章
cache—主存—辅存三级调度模拟
查看>>
Java线程的定义
查看>>
Python-面向对象(组合、封装与多态)
查看>>
Mininet
查看>>
COSC2531 Programming Fundamentals
查看>>
设计模式系列 - 访问者模式
查看>>
20180507小测
查看>>
eclipse左侧不见
查看>>
python会缓存小的整数和短小的字符
查看>>
格网与四叉树索引
查看>>
多张照片拍摄、图片浏览
查看>>
html(5) css
查看>>
Azure Web连接到Azure MySql Db
查看>>
Linux shell 命令判断执行语法 ; , && , ||
查看>>
vim代码格式化插件clang-format
查看>>
What does the dot after dollar sign mean in jQuery when declaring variables?
查看>>
windows registry
查看>>
jquery 动画总结(主要指效果函数)
查看>>
leetcode-17-电话号码的字母组合’
查看>>
Flume 示例
查看>>