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

Discrete Function(简单数学题)的更多相关文章

  1. URAL 1010 Discrete Function【简单暴力】

    链接:  http://acm.timus.ru/problem.aspx?space=1&num=1010 http://acm.hust.edu.cn/vjudge/contest/vie ...

  2. Ural 1010. Discrete Function

    1010. Discrete Function Time limit: 1.0 secondMemory limit: 64 MB There is a discrete function. It i ...

  3. HDU 6467 简单数学题 【递推公式 && O(1)优化乘法】(广东工业大学第十四届程序设计竞赛)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6467 简单数学题 Time Limit: 4000/2000 MS (Java/Others)    M ...

  4. HDU 6467.简单数学题-数学题 (“字节跳动-文远知行杯”广东工业大学第十四届程序设计竞赛)

    简单数学题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submi ...

  5. JZOJ 5773. 【NOIP2008模拟】简单数学题

    5773. [NOIP2008模拟]简单数学题 (File IO): input:math.in output:math.out Time Limits: 1000 ms  Memory Limits ...

  6. [JZOJ5773]【NOIP2008模拟】简单数学题

    Description       话说, 小X是个数学大佬,他喜欢做数学题.有一天,小X想考一考小Y.他问了小Y一道数学题.题目如下:      对于一个正整数N,存在一个正整数T(0<T&l ...

  7. geometry(简单数学题)

    geometry  Accepts: 324  Submissions: 622  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 6553 ...

  8. 管道函数(pipelined function)简单使用示例

    -----------------------------Cryking原创------------------------------ -----------------------转载请注明出处, ...

  9. NEFU 117 - 素数个数的位数 - [简单数学题]

    题目链接:http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=117 Time Limit:1000ms Memory Limi ...

随机推荐

  1. 前端打包利器:webpack工具

    一.什么是WebPack,为什么要使用它? 1.为什要使用WebPack 现今的很多网页其实可以看做是功能丰富的应用,它们拥有着复杂的JavaScript代码和一大堆依赖包.为了简化开发的复杂度,前端 ...

  2. js获取上传图片的尺寸大小

    当上传图片时,有时候需要控制下上传图片的尺寸大小,需要给个提示 //获取图片的尺寸,控制尺寸大小 var reader = new FileReader(), img = new Image(); / ...

  3. 用反射来了解Java中泛型的本质

    这篇文章主要通过Class的Method来了解泛型的本质. 先new 两个List,一个不加类型限制,另外一个限制类型为String: ArrayList list = new ArrayList() ...

  4. nodeJs-autoBulid

    /** * Created by Administrator on 2016/1/16. */ var projectData = { 'name' : 'autobulid', 'fileData' ...

  5. 系统封装 如何为原生PE集成软件

    1 我们首先集成Explorer.老外的BSExplorer比较好用,下载之后得到这些文件,不算太大.   2 这里需要注意,前一章讲解如何打造原生PE已经制作成了ISO,这里想要集成软件还需要回到刚 ...

  6. Input.GetAxis 获取轴

    static function GetAxis (axisName : string) : float Description描述 Returns the value of the virtual a ...

  7. 使用C++11封装线程池ThreadPool

    读本文之前,请务必阅读: 使用C++11的function/bind组件封装Thread以及回调函数的使用 Linux组件封装(五)一个生产者消费者问题示例   线程池本质上是一个生产者消费者模型,所 ...

  8. perftools查看堆外内存并解决hbase内存溢出

    最近线上运行的hbase发现分配了16g内存,但是实际使用了22g,堆外内存达到6g.感觉非常诡异.堆外内存用一般的工具很难查看,可以通过google-perftools来跟踪: http://cod ...

  9. jquery技术揭秘静态工具函数源码重构

    1.调用页面 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  10. vuejs 表单验证插件 VeeValidate

    VeeValidate https://baianat.github.io/vee-validate/