Discrete Function

There is a discrete function. It is specified for integer arguments from 1 to N (2 ≤ N ≤ 100000). Each value of the function is longint (signed long in C++). You have to find such two points of the function for which all points between them are below than straight line connecting them and inclination of this straight line is the largest.

Input

There is an N in the first line. Than N lines follow with the values of the function for the arguments 1, 2, …, N respectively.

Output

A pair of integers, which are abscissas of the desired points, should be written into one line of output. The first number must be less then the second one. If it is any ambiguity your program should write the pair with the smallest first number.

Example

input output
3
2
6
4
1 2

//简单数学题,题意是,在一个横坐标是 1 - N 的整数的坐标里,每个整数代表纵坐,若任意两个点都可连成一条直线,问倾角最大的两个点横坐标是?

//容易想到,必须是两个相邻的点才有可能倾角最大,所以一重循环就解决了

 #include<stdio.h>
#include<math.h>
double a[];
int main()
{
int n; scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%lf",&a[i]); int s=,e=;
double ans=-;
for(int i=;i<=n;i++)
{
double tmp=fabs(a[i]-a[i-]);
if(ans<tmp)
{
s=i-;
e=i;
ans=tmp;
}
}
printf("%d %d\n",s,e);
return ;
}

最新文章

  1. linux 安装maven
  2. ready与onload的性能
  3. Mac必装app-持续更新
  4. 图解equals与hashcode方法相等/不相等的互相关系
  5. python2 编码问题详解
  6. cout输出各种进制
  7. AVL树----java
  8. HTML表格标签的使用-&amp;lt;table&amp;gt;
  9. Hibernat之关系的处理一对一处理
  10. 我一个二本大学是如何拿到百度、网易大厂offer的!
  11. lnmp.org 安装环境的,root权限都没法删除网站文件夹,问题解决-转
  12. 简介 - MongoDB
  13. Charles设置HTTPS抓包
  14. Logistic Regression--逻辑回归算法汇总**
  15. linux 下 php 安装 ZeroMQ 扩展
  16. linux将指令加入开机启动或加入环境变量
  17. hibernate12--注解
  18. POJ 1986 Distance Queries 【输入YY &amp;&amp; LCA(Tarjan离线)】
  19. depletion mosfet 的 depletion 解釋
  20. JAVA Eclipse 创建android xml看不到预览怎么办

热门文章

  1. JAVA之HashMap集合
  2. pc_lint的用法转
  3. IDETalk
  4. spring-hadoop-samples
  5. spring boot 缺点优点?
  6. 2016.6.20 tomcat端口始终被占用
  7. 使用PowerDesigner进行代码生成
  8. 【Android工具类】怎样保证Android与server的DES加密保持一致
  9. Solidworks如何在装配图中保存单独的一个零件
  10. iOS 原生二维码扫描和生成