版本比较
出题人完全不会给题目起名字 题解
正文
增加 6 行删除 6 行
12 行未改动131415161717181920212 行未改动24252627282928293031323334353637383738394040414243449 行未改动12 行未改动视实现的精细程度可以做到 $O(n)$ 或者 $O(n\log n)$,不过我好像不太精细。
```cpp#include "bits/stdc++.h"#define int long long #define int long long#define f(i ,m ,n ,x) for (int i = (m) ; i <= (n) ; i += (x))
using arr = std :: array < int ,2 > ;const int N = 1e6 + 25 ;2 行未改动
signed main (void) { std :: ios :: sync_with_stdio (false) , std :: cin.tie (nullptr) ,std :: cout.tie (nullptr) ; std :: cin >> n ;
std :: cin >> n ; assert (n <= 1000000) ; f (i ,1 ,n ,1) { int x ,y ; std :: cin >> x >> y ; assert (x > 0 && x <= 1000000000 && y > 0 && y <= 1000000000) ; int d = std :: __gcd (x ,y) ; x /= d ,y /= d ; ps += (arr){x ,y} ; } std :: sort (ps.begin () ,ps.end () ,[] (const arr &x ,const arr &y)
std :: sort (ps.begin () ,ps.end () ,[] (const arr &x ,const arr &y) { return x[0] * y[1] > y[0] * x[1] ;}) ;
arr ans = *ps.begin () ; if (ans[0] <= ans[1]) { ans = *ps.rbegin () ; std :: cout << ans[0] << ' ' << ans[1] << '\n' ;9 行未改动