zoukankan      html  css  js  c++  java
  • 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);
        }
    }
    


查看全文
  • 相关阅读:
    计算时代之大数据-分类阅读时代
    从语言到库到框架,再到API,再到标记最后到DSL语言
    Angular指令1
    宇宙量子计算理论
    Angular实现瀑布流的库angular-deckgrid
    Markdown会干掉Html吗?
    基于Html5缓存的页面P2P技术可行性探讨
    一个艰难的决定
    CentOS7 安装 MariaDB-10.4.7
    MongoDB-4 GridFS 文件存储
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10960605.html
  • Copyright © 2011-2022 走看看