parent
1a070f67d9
commit
187ef655bf
@ -1,26 +1,39 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
// 1498 902
|
||||
|
||||
struct node {
|
||||
int x, y;
|
||||
};
|
||||
node a[110];
|
||||
int n, L;
|
||||
|
||||
vector<int> X, Y;
|
||||
|
||||
int ans;
|
||||
int main() {
|
||||
int n, d;
|
||||
cin >> n >> d; // 最后一个形式是: n/d
|
||||
// 最后一个数的小数
|
||||
double x = 1.0 * n / d;
|
||||
double pre = round(x); // 前一个小数
|
||||
// 第一个
|
||||
cout << pre << "/1" << endl;
|
||||
|
||||
// 从第二个开始
|
||||
// 分母
|
||||
for (int i = 1; i <= d; i++) {
|
||||
// 分子
|
||||
for (int j = 1; j <= n; j++) {
|
||||
double cur = 1.0 * j / i; // 当前枚举到的小数
|
||||
if (abs(cur - x) >= abs(pre - x)) continue; // 如果当前枚举到的小数与最后小数的距离,大于,上一个小数与最后小数的距离
|
||||
// 说明,现有枚举到的数更贴近目标,需要打印
|
||||
cout << j << "/" << i << endl;
|
||||
pre = cur; // 将上一个小数的距离更新为现在小数的距离,为了下一次循环做准备工作
|
||||
cin >> n >> L;
|
||||
for (int i = 1; i <= n; ++i) cin >> a[i].x >> a[i].y;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
X.push_back(a[i].x);
|
||||
X.push_back(a[i].x - L);
|
||||
Y.push_back(a[i].y);
|
||||
Y.push_back(a[i].y - L);
|
||||
}
|
||||
|
||||
for (int i = 0; i < X.size(); i++) {
|
||||
for (int j = 0; j < Y.size(); j++) {
|
||||
int cnt = 0;
|
||||
int lx = X[i], ly = Y[j];
|
||||
for (int k = 1; k <= n; k++)
|
||||
if (a[k].x >= lx && a[k].x <= lx + L && a[k].y >= ly && a[k].y <= ly + L)
|
||||
cnt++;
|
||||
|
||||
ans = max(ans, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue