input:slope.in output:slope.out

Time Limits: 1000 ms Memory Limits: 131072 KB

Description

Input

Output

Sample Input

1
2
3
4
5
6
7
6 15698 17433
112412868 636515040
122123982 526131695
58758943 343718480
447544052 640491230
162809501 315494932
870543506 895723090

Sample Output

1
193409386/235911335

Data Constraint

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 200005
int n;
ll P, Q, p, q;
double k = 1000000000, lastk;
struct Point {
ll x, y;
int num;
}s[N],t[N];
ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
bool cmp(Point a, Point b) {return a.y < b.y;}
double Abs(double x) {return x < 0 ? -x : x;}
double getk(Point a, Point b) {
return (double)(b.y - a.y) / (double)(b.x - a.x);
}
int main() {
freopen("slope.in", "r", stdin);
freopen("slope.out", "w", stdout);
scanf("%d%d%d", &n, &P, &Q);
for (int i = 1; i <= n; i++) {
scanf("%lld%lld", &s[i].x, &s[i].y);
t[i].x = Q * s[i].x;
t[i].y = Q * s[i].y - P * s[i].x;
t[i].num = i;
}
sort(t + 1, t + n + 1, cmp);
for (int i = 1; i < n; i++) {
double nowk = Abs(getk(t[i], t[i + 1]));
if (nowk < k) {
k = nowk;
p = s[t[i + 1].num].y - s[t[i].num].y;
q = s[t[i + 1].num].x - s[t[i].num].x;
lastk = getk(s[t[i].num], s[t[i + 1].num]);
}
else if (nowk == k) {
nowk = getk(s[t[i].num], s[t[i + 1].num]);
if (nowk < lastk) {
lastk = nowk;
p = s[t[i + 1].num].y - s[t[i].num].y;
q = s[t[i + 1].num].x - s[t[i].num].x;
}
}
}
p = Abs(p); q = Abs(q);
ll g = gcd(p, q);
printf("%lld/%lld\n", p / g, q / g);
return 0;
}