2 条题解
-
1
#include<iostream> #define x first #define y second using namespace std; const int N = 10010; typedef pair<int, int> PII; PII p[N]; int n; bool check01(int mid) { for (int i = 1; i <= n; ++ i) if ((p[i].x / mid) > p[i].y) return false; return true; } bool check02(int mid) { for (int i = 1; i <= n; ++ i) if ((p[i].x / mid) < p[i].y) return false; return true; } int main() { cin >> n; for (int i = 1; i <= n; ++ i) scanf("%d%d", &p[i].x, &p[i].y); int l = 1, r = 1e9; while (l < r) { int mid = (l + r) >> 1; if (check01(mid)) r = mid; else l = mid + 1; } cout << r << ' '; l = 1, r = 1e9; while (l < r) { int mid = (l + r + 1) >> 1; if (check02(mid)) l = mid; else r = mid - 1; } cout << l << endl; return 0; }
-
0
设答案为 , 因为能炼出 个但炼不出 个所以有 且 即
最小值 ,最大值
#include <iostream> #include <cstring> #include <algorithm> using namespace std; int main() { int n; scanf("%d", &n); int minn = 1, maxx = 1e9; while (n -- ) { int a, b; scanf("%d%d", &a, &b); minn = max(minn, a / (b + 1) + 1); maxx = min(maxx, a / b); } printf("%d %d\n", minn, maxx); return 0; }
- 1
信息
- ID
- 5502
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 5
- 已通过
- 2
- 上传者