QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137559 | #2350. Integer Cow | S_Explosion# | RE | 0ms | 0kb | C++20 | 1.6kb | 2023-08-10 13:57:48 | 2023-08-10 13:59:01 |
Judging History
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