枚举半径,然后控制角度。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ss(x) scanf("%d",&x)
const double pi=acos(-1.0);
const int maxn=5000+10;
const int inf=0x3f3f3f3f;
struct node{
int x,y;
double r,c;
int cnt;
void get(){
ss(x);ss(y);
r=sqrt(x*x*1.0+y*y*1.0);
c=atan2(y,x);
cnt=1;
}
}p[maxn],rec[maxn];
int n,k;
bool cmp1(const node &a,const node &b) {return a.r<b.r;}
bool cmp2(const node &a,const node &b) {return a.c<b.c;}
double solve()
{
if(k==0) return 0;
sort(p,p+n,cmp2);
double ans=inf;
set<double> v;
rep(i,0,n){
if(p[i].cnt<k) continue;
double R=p[i].r,C=2*pi;
if(v.find(R)!=v.end()) continue;
v.insert(R);
int tmp=0;
rep(j,0,n){
if(p[j].r<R||fabs(p[j].r-R)<1e-9){//精度问题,所以在半径周围1e-9的圆周内的点也算进扇形包括的点中
rec[tmp++]=p[j];
if(tmp>=k) C=min(C,rec[tmp-1].c-rec[tmp-k].c);
}
}
if(tmp<k) continue;
rep(j,0,k-1) C=min(C,rec[j].c-rec[tmp+j-k+1].c+2*pi);
ans=min(ans,R*R*C/2);
}
return ans;
}
int main()
{
int cas=0;
while (true)
{
ss(n);ss(k);if(n+k==0) break;
rep(i,0,n) p[i].get();
sort(p,p+n,cmp1);
rep(i,1,n) p[i].cnt+=p[i-1].cnt;
printf("Case #%d: %.2lf\n", ++cas, solve());
}
return 0;
}