URAL 1010 Discrete Function(解题报告)
2012-09-04 13:42
381 查看
Description
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.
Sample Input
这个题看了老半天才懂。这么解释吧,设离散函数为f(n),根据输入数据则是,f(1) = 2;
f(2) = 6; f(3) = 4.现在有三个点 了对吧,现在就是要从这三个点中找出两个点,使在这两个点之间的点不能再这条直线的上方,并且倾角(注意:不是斜率,是倾角)要最大。显然,如果有点在一条直线下的话那么这条直线倾角绝对不是最大的,所以满足题意的答案必然是两个相邻的点,题目就转化为了求相邻点距离的绝对值了。
[/code]
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.
Sample Input
input | output |
---|---|
3 2 6 4 | 1 2 |
f(2) = 6; f(3) = 4.现在有三个点 了对吧,现在就是要从这三个点中找出两个点,使在这两个点之间的点不能再这条直线的上方,并且倾角(注意:不是斜率,是倾角)要最大。显然,如果有点在一条直线下的话那么这条直线倾角绝对不是最大的,所以满足题意的答案必然是两个相邻的点,题目就转化为了求相邻点距离的绝对值了。
#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> using namespace std; int main() { long long int a[100001]; int n,t,i; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%lld",&a[i]); } long long max=-1; for(i=2;i<=n;i++) { if(llabs(a[i]-a[i-1])>max) { max=llabs(a[i]-a[i-1]); t=i; } } printf("%d %d\n",t-1,t); return 0; }
[/code]
相关文章推荐
- URAL 1010 Discrete Function(解题报告)
- [解题报告]Ural 1010 Discrete Function
- ural1010 Discrete Function
- URAL 1010 Discrete Function
- ural 1010. Discrete Function
- URAL 1010 Discrete Function
- URAL1010 - Discrete Function - 水题
- URAL 1010 Discrete Function【简单暴力】
- URAL 1010 Discrete Function【简单暴力】
- ural 1010. Discrete Function
- ural 1010 Discrete Function
- URAL 1010 - Discrete Function
- ural 1010. Discrete Function
- 解题报告 Function
- HDU - 1010 Tempter of the Bone 深搜模板题(DFS)解题报告
- [解题报告]ural 1163 Chapaev
- poj 1010 STAMPS 解题报告 -- 搜索 遍历 剪枝
- HDU 1010 Tempter of the Bone 解题报告
- URAL 1699 Turning Turtles 解题报告
- RQNOJ 107 Ural的鹰蛋实验 解题报告