【BZOJ3834】【POI2014】Solar Panels

【题目链接】

【思路要点】

  • 补档博客,无题解。

【代码】

#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {int x, y; };
int alen, blen;
info a[MAXN], b[MAXN];
void get(int l, int r, int &tot, info *res) {
	int nxt = 0; tot = 0;
	for (int i = 1; i <= l; i = nxt + 1) {
		if (i == l) nxt = l;
		else nxt = (l - 1) / ((l - 1) / i);
		res[++tot] = (info) {(l - 1) / i + 1, r / i};
		if (res[tot].x > res[tot].y) tot--;
	}
}
int main() {
	int T; read(T);
	while (T--) {
		int xl, xr, yl, yr;
		read(xl), read(xr), read(yl), read(yr);
		get(xl, xr, alen, a);
		get(yl, yr, blen, b);
		int now = 1, ans = 0;
		for (int i = 1; i <= alen; i++) {
			while (now <= blen && b[now].x > a[i].y) now++;
			if (now <= blen && max(b[now].x, a[i].x) <= min(b[now].y, a[i].y)) ans = max(ans, min(b[now].y, a[i].y));
		}
		printf("%d\n", ans);
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值