QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137521 | #2350. Integer Cow | S_Explosion# | TL | 1913ms | 3536kb | C++14 | 1.2kb | 2023-08-10 13:43:45 | 2023-08-10 13:43:47 |
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;
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);
ll X,Y;
cin>>T;
while(T--){
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-2500;X<=X1+2500;X++)
for(Y=Y1-2500;Y<=Y1+2500;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;
}
cout<<1<<'\n';
cout<<X0<<' '<<Y0<<' '<<ansX<<' '<<ansY<<'\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 51ms
memory: 3480kb
input:
3 1 2 1 1 2 3 2 5 -10 3 0 0 1 10 0
output:
0 1 2 1 -10 3 -2 2 1 10 0 1 0
result:
ok correct (3 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
1 0 0 1 0 0
output:
0 0 0
result:
ok correct (1 test case)
Test #3:
score: 0
Accepted
time: 1913ms
memory: 3536kb
input:
100 -1 0 2 -3 -2 0 -2 2 -2 0 2 -1 1 0 1 -1 -3 1 -1 0 -1 2 2 -1 -1 2 -2 2 0 -3 -2 -3 2 -3 -2 0 1 2 2 1 -1 0 1 -2 -2 2 -2 2 -1 -2 1 2 2 -2 2 -1 2 1 -1 2 -2 1 2 -3 -2 -1 1 1 -1 1 2 2 1 1 -3 2 0 1 -2 -1 -1 2 1 -2 0 2 -2 2 -2 -1 -2 -2 1 1 -2 -1 1 2 2 1 2 -3 1 0 -1 -3 -3 2 2 -1 2 1 1 -1 1 -3 -2 1 -2 -3 0 ...
output:
1 -3 -2 -2 -1 1 -2 0 -1 -1 1 0 1 1 -1 1 -1 0 -1 -2 1 -1 -1 -1 0 1 0 -3 0 -2 0 -3 -2 0 2 1 1 -2 -2 -1 -1 1 -1 -2 0 -2 1 -2 2 -1 2 0 -1 2 1 -3 -2 -2 -1 0 -1 1 1 1 -3 2 1 1 -2 -1 1 0 1 -2 0 -1 1 1 -2 -1 0 -2 1 1 -2 -1 -2 1 2 1 1 1 1 0 -1 1 -3 1 2 -1 -1 -3 1 -1 1 1 1 1 -2 -3 -3 -3 0 -2 -2 0 -2 -2 0 1 -1...
result:
ok correct (100 test cases)
Test #4:
score: -100
Time Limit Exceeded
input:
100 -5 9 1 -2 -7 3 1 6 9 2 -2 -1 2 -7 3 -10 -8 7 -8 6 0 3 9 -6 -7 6 4 9 -1 4 8 6 7 -7 7 3 -7 7 2 0 -5 -1 6 -7 -7 -5 8 7 -9 -6 -6 -5 5 -10 -9 -7 1 9 7 -2 -4 9 4 8 3 3 -9 6 2 -2 -1 -7 3 -8 2 -2 -5 4 -1 0 1 2 9 -5 5 0 9 5 -4 -1 -10 8 2 -3 -7 -8 -3 3 2 -3 3 3 7 -4 6 6 0 6 -3 5 -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