QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575483 | #3195. Within Arm's Reach | qwqUwU_ | AC ✓ | 1ms | 4356kb | C++14 | 1.8kb | 2024-09-19 14:43:01 | 2024-09-19 14:43:01 |
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);
if(px==0&&py==0)px=py=eps,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){
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: 1ms
memory: 3908kb
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: 3852kb
input:
1 10 10 0
output:
10.000000 0.000000
result:
ok ACCEPTED
Test #3:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
1 10 0 0
output:
7.071068 7.071068
result:
ok ACCEPTED
Test #4:
score: 0
Accepted
time: 0ms
memory: 3860kb
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: 4248kb
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: 4256kb
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: 4232kb
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: 3812kb
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: 4152kb
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: 4220kb
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: 0
Accepted
time: 0ms
memory: 4160kb
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:
744.807903 538.351360 302.866165 96.409622 967.439050 576.766657 536.811020 146.138627 1152.756620 591.347587 1123.765242 562.356209 1052.347457 490.938424 888.298684 326.889651 502.925488 -58.483545 1161.014735 417.187080 995.551748 251.724093 870.393848 126.566193 461.015854 667.023091 368.384866 ...
result:
ok ACCEPTED
Test #13:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
20 919 625 820 609 760 41 101 232 545 812 234 177 678 131 359 444 519 77 173 917 0 -20000
output:
0.000000 -919.000000 0.000000 -1544.000000 0.000000 -2364.000000 0.000000 -2973.000000 0.000000 -3733.000000 0.000000 -3774.000000 0.000000 -3875.000000 0.000000 -4107.000000 0.000000 -4652.000000 0.000000 -5464.000000 0.000000 -5698.000000 0.000000 -5875.000000 0.000000 -6553.000000 0.000000 -6684....
result:
ok ACCEPTED
Test #14:
score: 0
Accepted
time: 0ms
memory: 4356kb
input:
20 408 663 148 685 731 606 538 289 850 577 732 34 656 200 325 901 105 575 754 910 -2498 1075
output:
374.770190 -161.280206 -255.668910 43.940507 -119.722861 -14.563097 -771.081509 197.467353 -1466.181030 423.736344 -909.537071 184.187804 -415.354811 -28.480703 -149.892593 -142.720849 -958.147850 120.382629 -428.141968 -107.702368 -1124.192378 118.876157 -1092.961528 105.436140 -1165.828939 757.376...
result:
ok ACCEPTED
Test #15:
score: 0
Accepted
time: 0ms
memory: 4260kb
input:
20 440 377 296 985 425 377 777 533 710 620 975 854 312 130 13 900 745 416 550 507 -1080 -2184
output:
195.038398 394.410983 362.150844 732.349484 493.358493 997.680509 -5.256034 148.205051 183.133328 529.170204 350.245774 867.108706 -43.077564 197.014867 193.184859 674.789990 -166.222567 62.477731 -480.071304 -472.217481 -973.623755 -1313.068823 -1405.925081 -2049.568357 -1267.625126 -1769.895115 -1...
result:
ok ACCEPTED
Test #16:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
4 890 306 65 120 -10 14
output:
-517.301992 724.222789 -339.443105 475.220347 -301.662623 422.327672 -231.914039 324.679655
result:
ok ACCEPTED
Test #17:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
20 149 380 248 401 43 631 977 207 511 496 14 425 179 867 9 801 432 766 684 358 -3887 7982
output:
-65.234837 133.960502 -231.605563 475.604734 -340.184352 698.572549 -515.749249 1059.097121 -534.575411 1097.756863 -810.838379 1665.066102 -1238.586271 2543.451405 -1329.214534 2729.557606 -1552.939378 3188.979192 -1770.096957 3634.914822 -1776.226405 3647.501715 -1962.298927 4029.603817 -2040.6682...
result:
ok ACCEPTED
Test #18:
score: 0
Accepted
time: 0ms
memory: 4220kb
input:
20 121 803 712 959 971 452 892 694 465 489 201 20 757 995 643 853 797 755 203 452 2501 643
output:
-117.188936 -30.128943 677.475279 85.273767 -12.099289 -92.013897 936.945521 45.808269 1897.865761 185.355008 1460.102131 72.807221 2342.842454 201.000518 1670.700951 28.194846 1220.346774 -87.589934 746.748511 -209.350703 552.079286 -259.399608 532.709214 -264.379599 1281.850946 -155.587754 2266.52...
result:
ok ACCEPTED
Test #19:
score: 0
Accepted
time: 0ms
memory: 4288kb
input:
20 397 740 397 939 260 942 166 856 939 700 98 740 470 621 506 843 433 261 951 662 10019 -4091
output:
369.574338 -144.995892 1058.453456 -415.265314 1428.027794 -560.261206 2302.159541 -903.211188 2061.452708 -804.924767 2938.377207 -1148.970435 2784.695152 -1086.218336 3581.560727 -1398.854315 4455.692473 -1741.804297 5107.334883 -1997.464560 5016.606923 -1960.418140 5705.486041 -2230.687561 6143.0...
result:
ok ACCEPTED
Test #20:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
6 870 915 808 598 10 881 -4251 -946
output:
-849.226299 -188.983316 -1742.378095 -387.741632 -2531.084818 -563.257172 -3114.805883 -693.156049 -3124.567105 -695.328271 -3984.530748 -886.701032
result:
ok ACCEPTED
Test #21:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
1 500 -40 80
output:
-223.606798 447.213595
result:
ok ACCEPTED