【HDU 6158】The Designer(圆的反演)

传送门

对切点反演之后就是两个平行线之间赛圆
直接做即可,在圆的面积足够小的时候 b r e a k break break即可

#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define bg begin
#define fi first
#define se second
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline int readstring(char *s){
    int top=0;char ch=gc();
    while(isspace(ch))ch=gc();
    while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
    return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a<b?a=b:0;}
template<typename tp>inline void chemn(tp &a,tp b){a>b?a=b:0;}
namespace Module{
cs int mod=998244353;
inline int add(int a,int b){return (a+b>=mod)?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){static ll r;r=1ll*a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){a=(a+b>=mod)?(a+b-mod):(a+b);}
inline void Dec(int &a,int b){a=(a<b)?(a-b+mod):(a-b);}
inline void Mul(int a,int b){static ll r;r=1ll*a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(ll x){x%=mod,(x<0)&&(x+=mod);return x;}
}
cs int N=200010;
struct pt{
    double x,y;
    pt(double _x=0,double _y=0):x(_x),y(_y){}
    friend inline pt operator +(cs pt &a,cs pt &b){
        return pt(a.x+b.x,a.y+b.y);
    }
    friend inline pt operator -(cs pt &a,cs pt &b){
        return pt(a.x-b.x,a.y-b.y);
    }
    friend inline double operator *(cs pt &a,cs pt &b){
        return a.x*b.y-a.y*b.x;
    }
    friend inline double operator ^(cs pt &a,cs pt &b){
        return a.x*b.x-a.y*b.y;
    }
    friend inline pt operator *(cs pt &a,cs double &b){
        return pt(a.x*b,a.y*b);
    }
    friend inline pt operator /(cs pt &a,cs double &b){
        return pt(a.x/b,a.y/b);
    }
    inline pt move(double a,double d){return pt(x+d*cos(a),y+d*sin(a));}
    inline double ang(){return atan2(y,x);}
    inline double dis(){return sqrt(x*x+y*y);}
}P,A,B;
cs double eps=1e-14,INF=1e12,pi=acos(-1);
inline int sign(double x){
    return (x>eps)-(x<-eps);
}
inline double sqr(double x){return x*x;}
struct cir{
    pt o;double r;
    cir(){}
    cir(pt x,double _r){o=x,r=_r;}
    inline double S(){return pi*sqr(r);}
};
double r1,r2,r;
int n;
cs double R=6.0;
inline cir CInv(cir A){
    cir res;
    double oc1=(A.o-P).dis();
    double v1=1.0/(oc1-A.r),v2=1.0/(oc1+A.r),oc2=0.5*R*R*(v1+v2);
    res.r=0.5*R*R*(v1-v2),res.o=P+(A.o-P)*(oc2/oc1);
    return res;
}
int main(){
    #ifdef Stargazer
    freopen("lx.in","r",stdin);
    #endif
    int T=read();
    while(T--){
        r1=read(),r2=read();
        n=read();double ans=0;
        if(r1<r2)swap(r1,r2);
        r1=R*R/(r1*2.0),r2=R*R/(r2*2.0);
        r=(r2-r1)*0.5;
        cir x,now;x.o=pt((r1+r2)*0.5,0);
        x.r=r;now=CInv(x),ans+=now.S();
        for(int i=2;i<=n;i++){
            if((i&1)==0){
                x.o.y+=r*2.0;
                now=CInv(x);
            }
            ans+=now.S();
            if(sign(now.S())!=1)break;
        }
        printf("%.5lf\n",ans);
    }return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值