Discrete Function(timus1010,暴力)
来源:互联网 发布:社交网络的坏处 编辑:程序博客网 时间:2024/05/17 02:08
http://acm.timus.ru/problem.aspx?space=1&num=1010
1010. Discrete Function
Time limit: 1.0 second
Memory limit: 64 MB
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 output
3
2
6
4
1 2
Problem Source: Third Open USTU Collegiate Programming Contest (PhysTech Cup), March 18, 2000
Tags: none (hide tags for unsolved problems)
Difficulty: 245 Printable version Submit solution Discussion (62)
All submissions (21340) All accepted submissions (5687) Solutions rating (4180)
解析:只计算相邻的斜率即可;
注意绝对值
*/
#include<stdio.h>#include<string.h>#include<math.h>#include <iostream>using namespace std;const int maxn=1000000+10;double y[maxn];int main(){ int n; int i,j; double max,k; while(scanf("%d",&n)!=EOF) { for(i=1;i<=n;i++) cin>>y[i]; int x1; max=-1; for(i=2;i<=n;i++) { k=y[i]-y[i-1]; if(max<fabs(k)) {x1=i-1; max=fabs(k); } } printf("%d %d\n",x1,x1+1); } return 0;}
- Discrete Function(timus1010,暴力)
- URAL 1010 Discrete Function【简单暴力】
- hdu5875 Function(暴力)
- ural 1010. Discrete Function
- ural 1010. Discrete Function
- 1010. Discrete Function
- URAL 1010 - Discrete Function
- URAL 1010 Discrete Function
- URAL1010 - Discrete Function - 水题
- 寒假集训.Discrete-Function
- ural1010 Discrete Function
- URAL 1010|Discrete Function
- [解题报告]Ural 1010 Discrete Function
- URAL 1010 Discrete Function(解题报告)
- URAL 1010 Discrete Function(解题报告)
- 大暴力 Function
- 离散傅立叶变换(Discrete Fourier Transform)
- 离散余弦变换(Discrete Cosine Transform)
- 小Q系列故事——大笨钟
- Minimal Coverage(ural1303,区间贪心)
- HTTP消息头
- New Year Bonus Grant(SGU195,贪心or区间DP)
- 手工打造可执行程序
- Discrete Function(timus1010,暴力)
- 【rmzt】黄昏少女&&失忆win7主题_8.18
- 文件拖拽效果----C++实现
- hdu4515 小Q系列故事——世界上最遥远的距离
- Best Time to Buy and Sell Stock II
- Coin Change(hdu2069,暴力or母函数)
- ASP.NET中利用Split实现对Checkbox的字符串分离放到DataTable里面
- 利用JFormattedTextField创建一个只能输入数字的文本框
- 英文数字转换成为阿拉伯数字