QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137559#2350. Integer CowS_Explosion#RE 0ms0kbC++201.6kb2023-08-10 13:57:482023-08-10 13:59:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 13:59:01]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-08-10 13:57:48]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long double ld;
typedef long long ll;
const ld eps=1e-10;
int T;
ll r,Xc,Yc,X0,Y0,ansX,ansY,ans,curx,cury;
ld X1,Y1,l;
ll dist2(ll X1,ll Y1,ll X2,ll Y2){
    return (X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2);
}
ld dist(ld X1,ld Y1,ld X2,ld Y2){
    return sqrtl((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
}
bool is_point_in_circle(ll X0,ll Y0,ll Xc,ll Yc,ll r){
    return dist2(X0,Y0,Xc,Yc)<=r*r;
}
int main(){
    ios::sync_with_stdio(false);
    srand(725);
    ll X,Y;
    cin>>T;
    while(T--){
        int try_time=1e5;
        ans=9e18;
        cin>>Xc>>Yc>>r>>X0>>Y0;
        if(is_point_in_circle(X0,Y0,Xc,Yc,r)){
            cout<<0<<'\n';
            cout<<X0<<' '<<Y0<<'\n';
            continue;
        }
        l=dist(X0,Y0,Xc,Yc);
        X1=((l-r)*Xc+r*X0)/l;
        Y1=((l-r)*Yc+r*Y0)/l;
        for(X=X1-1000;X<=X1+1000;X++)
            for(Y=Y1-1000;Y<=Y1+1000;Y++){
                if(!is_point_in_circle(X,Y,Xc,Yc,r))
                    continue;
                ll cur=dist2(X0,Y0,X,Y);
                if(cur<ans)
                    ans=cur,ansX=X,ansY=Y;
            }
        while(try_time--){
            X=ansX+rand()%(try_time)-(try_time+1)/2;
            Y=ansY+rand()%(try_time)-(try_time+1)/2;
            if(!is_point_in_circle(X,Y,Xc,Yc,r))
                continue;
            ll cur=dist2(X0,Y0,X,Y);
            if(cur<ans)
                ans=cur,ansX=X,ansY=Y;
        }
        cout<<1<<'\n';
        cout<<X0<<' '<<Y0<<' '<<ansX<<' '<<ansY<<'\n';
    }
    return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

3
1 2 1 1 2
3 2 5 -10 3
0 0 1 10 0

output:

0
1 2

result: