• HDU 1594 find the max


    数序问题。


    题意是说 一个数列 a1,a2,……ai,……an;  x=i , y = ai;找两个点斜率绝对值。!最大。

    第一次没找绝对值,……认真读题。

    。。

    x 每次加1 。

    仅仅须要找 相邻的 ai 是否是最大就好了。


    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<queue>
    #include<algorithm>
    #include<map>
    #include<stack>
    #include<iostream>
    #include<list>
    #include<set>
    #include<cmath>
    #define INF 0x7fffffff
    #define eps 1e-6
    #define LL long long
    using namespace std;
    int main()
    {
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            int a,b,m=0,tmp;
            scanf("%d",&a);
            for(int i=1;i<n;i++)
            {
                scanf("%d",&b);
                if(m<abs(a-b))
                    m=abs(a-b),tmp=i;
                a=b;
            }
            printf("%d %d
    ",tmp,tmp+1);
        }
    }
    


  • 相关阅读:
    javax.xml.ws.WebServiceException: Provider com.sun.xml.ws.spi.ProviderImpl not found
    注意资源利用 不然导致资源消耗会很严重
    E212: 不能以写入模式打开 linux
    安装db2 提示不是有效的win32应用程序?
    对苹果“五仁”编程语言Swift的简单分析
    Spoj 1557 Can you answer these queries II 线段树 随意区间最大子段和 不反复数字
    Oracle 学习笔记 14 -- 集合操作和高级子查询
    PHP的curl库代码使用
    AWS OpsWorks新增Amazon RDS支持
    最短编辑距离算法
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10960605.html
  • Copyright © 2020-2023  润新知