2025 United Kingdom and Ireland Programming Contest (UKIEPC 2025) 2025 英国 ICPC——E. Enclosure · znzryb
## 题目大意
"
Pahom 从黎明开始,到日落结束,使用铲子做标记,走动的区域尽可能大。由标记点组成的多边形代表Pahom所宣称的土地。
Pahom 每秒走一米,每个标记点需要 $m$ 秒制作,从黎明到日落总共有 $t$ 秒可用时间。找出Pahom可以宣称的最大区域。
Pahom必须在结束时返回起点。
"
## 思路讲解
这个函数可以三分啊。对,就是可以三分嗯。

P的这个单调性和 tan 的单调性是相反的。

从图像上,可以看出其上升速度是比较缓慢的,和 x 同阶。
```cpp
auto fx=[&](ll n) -> DB {
ll perimeter=total_tim-n*mark_time;
DB res=0.5*perimeter*perimeter/(2.0*n);
res/=tan(pi/n);
return res;
};
while (r-l>9) {
ll mid1=l+(r-l)/3,mid2=r-(r-l)/3;
if (fx(mid1)>fx(mid2)) {
r=mid2;
}else {
l=mid1;
}
}
```
## AC代码
AC
[https://qoj.ac/submission/2010802](https://qoj.ac/submission/2010802)
::: 源代码
```cpp
/**
* Problem: E. Enclosure
* Contest: 2025 United Kingdom and Ireland Programming Contest (UKIEPC 2025)
* Judge: Codeforces
* URL: https://codeforces.com/gym/106157/problem/E
* Created: 2026-02-06 17:13:53
* Author: Gospel_rock
*
* Powered by AutoCp https://github.com/Pushpavel/AutoCp
*/
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define lson(o) (o<<1)
#define rson(o) (o<<1|1)
#define SZ(a) ((long long) a.size())
#define debug(var) cerr << #var <<":"<<var<<"\n";
#define cend cerr<<"\n-----------\n"
#define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using DB = long double;
// using i128 = __int128;
using CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1;
static constexpr ll mod = 998244353; // (ll)1e9+7;
static constexpr double eps = 1e-8;
const double pi = acos(-1.0);
ll lT,testcase;
/*
*
*/
void Solve() {
ll mark_time,total_tim;
cin >> mark_time >> total_tim;
if (total_tim-3*mark_time<0) {
cout<<0<<"\n";
return;
}
ll l=3,r=total_tim/mark_time;
auto fx=[&](ll n) -> DB {
ll perimeter=total_tim-n*mark_time;
DB res=0.5*perimeter*perimeter/(2.0*n);
res/=tan(pi/n);
return res;
};
while (r-l>9) {
ll mid1=l+(r-l)/3,mid2=r-(r-l)/3;
if (fx(mid1)>fx(mid2)) {
r=mid2;
}else {
l=mid1;
}
}
DB ans=0;
for (ll i=l;i<=r;++i) {
ans=max(ans,fx(i));
}
cout<<fsp(12)<<ans<<"\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef LOCAL
cout.setf(ios::unitbuf); // 无缓冲流,方便我们调试
#endif
cin >> lT;
for (testcase=1;testcase<=lT;++testcase)
Solve();
return 0;
}
/*
AC
https://qoj.ac/submission/2010802
1
1 27
*/
```
:::
## 心路历程(WA,TLE,MLE……)