QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575474 | #3195. Within Arm's Reach | qwqUwU_ | WA | 0ms | 4288kb | C++14 | 1.8kb | 2024-09-19 14:39:03 | 2024-09-19 14:39:03 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
const int N=23;
const double eps=1e-8;
int n,id[N];
double a[N],x[N],y[N];
int main() {
//freopen("data.in", "r", stdin);
n=read();rep(i,1,n)a[i]=read(),id[i]=i;
sort(id+1,id+n+1,[](int i,int j){return a[i]<a[j];});
double px=read(),py=read(),len=sqrt(px*px+py*py);
double s=0,s2=0;rep(i,1,n)s+=a[i];
double X=0,Y=0;
bool fl1=0,fl2=0;
if(px<0)fl1=1,px=-px;
if(py<0)fl2=1,py=-py;
if(s<=len){
rep(i,1,n){
x[i]=px*(a[i]/len);
y[i]=py*(a[i]/len);
}
}
else{
rep(i,1,n){
int j=id[i];
if(s-s2-2*a[j]>=len){
s2+=a[j];s-=a[j];
x[j]=-px*(a[j]/len);
y[j]=-py*(a[j]/len);
X+=x[j],Y+=y[j];
continue;
}
if(i==n){
if(len==0)x[j]=a[j],y[j]=0;
else x[j]=px*(a[j]/len),y[j]=py*(a[j]/len);
break;
}
s-=a[j];s2+=len;
double k=py/px;
double c=(a[j]*a[j]+s2*s2-s*s)/(2*a[j]*s2);
double theta=acos(c)+atan(k);
x[j]=a[j]*cos(theta);
y[j]=a[j]*sin(theta);
c=(s2*s2+s*s-a[j]*a[j])/(2*s*s2);
theta=atan(k)-acos(c);
rep(j,i+1,n){
int k=id[j];
x[k]=a[k]*cos(theta);
y[k]=a[k]*sin(theta);
}
break;
}
}
rep(i,1,n){
x[i]+=x[i-1],y[i]+=y[i-1];
printf("%.6lf %.6lf\n",fl1?-x[i]:x[i],fl2?-y[i]:y[i]);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
2 4 2 -8 -3
output:
-3.745317 -1.404494 -5.617975 -2.106741
result:
ok ACCEPTED
Test #2:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
1 10 10 0
output:
10.000000 0.000000
result:
ok ACCEPTED
Test #3:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
1 10 0 0
output:
10.000000 0.000000
result:
ok ACCEPTED
Test #4:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
2 10 5 2 2
output:
7.071068 7.071068 3.535534 3.535534
result:
ok ACCEPTED
Test #5:
score: 0
Accepted
time: 0ms
memory: 4156kb
input:
3 100 20 20 80 90
output:
77.906765 62.693987 64.418647 77.461203 80.000000 90.000000
result:
ok ACCEPTED
Test #6:
score: 0
Accepted
time: 0ms
memory: 4156kb
input:
3 5 10 4 5 3
output:
-1.565244 4.748685 8.429972 5.057983 5.000000 3.000000
result:
ok ACCEPTED
Test #7:
score: 0
Accepted
time: 0ms
memory: 4288kb
input:
3 3 3 3 -1 -1
output:
2.121320 2.121320 1.997441 -0.876121 -1.000000 -1.000000
result:
ok ACCEPTED
Test #8:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
11 31 1 62 125 250 500 2 7 3 1000 15 -2 -3
output:
17.195706 25.793559 17.750406 26.625609 52.141818 78.212728 121.479343 182.219014 260.154392 390.231588 537.504490 806.256735 538.613891 807.920836 542.496792 813.745188 544.160892 816.241339 -10.539304 -15.808956 -2.218801 -3.328201
result:
ok ACCEPTED
Test #9:
score: 0
Accepted
time: 0ms
memory: 4156kb
input:
3 5 3 4 5 3
output:
4.666947 1.794327 2.094468 0.250840 5.000000 3.000000
result:
ok ACCEPTED
Test #10:
score: 0
Accepted
time: 0ms
memory: 4236kb
input:
20 3 9 15 5 7 13 4 17 8 999 16 6 10 14 2 12 1000 11 998 1 234 -123
output:
-2.655493 1.395836 -10.621971 5.583344 -23.899435 12.562524 -28.325256 14.888917 -34.521406 18.145867 -46.028542 24.194490 -49.569199 26.055605 -64.616991 33.965342 -71.698305 37.687571 225.682775 -916.023860 211.520146 -908.579402 206.209161 -905.787730 197.357518 -901.134943 184.965219 -894.621042...
result:
ok ACCEPTED
Test #11:
score: 0
Accepted
time: 0ms
memory: 4264kb
input:
20 11 857 509 877 13 811 991 997 937 853 787 739 919 7 859 941 929 773 947 863 9871 -7919
output:
-8.580136 6.883405 688.163995 -492.112203 291.137713 -173.598260 1004.141916 -684.239040 994.001756 -676.104106 1653.347718 -1148.315819 2459.034338 -1725.334077 3269.598980 -2305.845887 4031.383402 -2851.422182 4724.875518 -3348.088756 5364.709393 -3806.326263 4810.634326 -4295.327101 5557.784683 -...
result:
ok ACCEPTED
Test #12:
score: -100
Wrong Answer
time: 0ms
memory: 4188kb
input:
20 919 625 820 609 760 41 101 232 545 812 234 177 678 131 359 444 519 77 173 917 0 0
output:
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
result:
wrong output format Expected double, but "-nan" found