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);
        }
    }
    


查看全文
  • 相关阅读:
    logback 打印mybatis sql mybatis 日志打印sql语句和返回结果
    SpringBoot使用logback输出日志并打印sql信息 --经典---
    Logback设置SQL参数打印
    springboot2.X整合mybatis
    异常解决:java.lang.IllegalStateException: Failed to introspect Class
    springboot 启动报错 java.lang.IllegalStateException: Failed to introspect annotated methods on class org
    数据库相关中间件介绍
    QWaitCondition 的正确使用方法(通过 mutex 把有严格时序要求的代码保护起来,同时把 wakeAll() 也用同一个 mutex 保护起来)
    对生产者和消费者问题的另一个解决办法是使用QWaitCondition(封装好了wakeOne,wakeAll,而且与QReadWriteLock对接,几乎是万能的办法)
    Linux定时器的使用(三种方法)
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10960605.html
  • Copyright © 2011-2022 走看看