博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Discrete Function(简单数学题)
阅读量:7100 次
发布时间:2019-06-28

本文共 1240 字,大约阅读时间需要 4 分钟。

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
3264
1 2

 

 

 

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

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

1 #include
2 #include
3 double a[100005]; 4 int main() 5 { 6 int n; 7 8 scanf("%d",&n); 9 for(int i=1;i<=n;i++) scanf("%lf",&a[i]);10 11 int s=1,e=2;12 double ans=-1;13 for(int i=2;i<=n;i++)14 {15 double tmp=fabs(a[i]-a[i-1]);16 if(ans
View Code

 

转载于:https://www.cnblogs.com/haoabcd2010/p/6171416.html

你可能感兴趣的文章
CentOS6.5+puppet3.7.3 安装、配置及测试
查看>>
(转载)showModalDialog关闭子窗口刷新主窗口
查看>>
ACM HDU 1219 AC me(简单题,但是花了很长时间才AC)
查看>>
Ethernet LEDs
查看>>
row_number()over函数的使用(转)
查看>>
怎样在Delphi中屏蔽Flash控件的右键弹出菜单
查看>>
[BuildRelease]Mozilla Build Tools - Autoconf + GNU Make
查看>>
DRM-内容数据版权加密保护技术学习(上):视频文件打包实现(转)
查看>>
Html.ActionLink 几种重载方式说明及例子
查看>>
[转]spinlock 理解
查看>>
今天看腾讯在北航的演讲《1亿在线背后的技术挑战》想到的关于MD5算法。
查看>>
SQL高级---SQL Alias(别名)
查看>>
Android开发历程_5(Activity相对布局)
查看>>
OSI
查看>>
方法论、方法论——程序员的阿喀琉斯之踵 (转载)
查看>>
对架构师而言,什么最重要?
查看>>
ecshop foreach控制文章显示条数
查看>>
WPF Button添加图片
查看>>
TabHost的两种实现形式
查看>>
Sharepoint学习笔记—Site Definition系列-- 2、创建Content Type
查看>>