# Untitled

unknown
plain_text
7 months ago
1.2 kB
0
Indexable
Never
```#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;

#define DIV 0.000000001

int T, tc;
int N;
int coor[10];
int mass[10];
double left_p;
double right_p;
double mid_p;
double force_sum;
double balance_p;

void find_balance()
{
force_sum=0;
mid_p = (left_p + right_p)/2;
for(int p=0; p<N; p++){
if(mid_p>coor[p]){
force_sum -= mass[p] / ((mid_p - coor[p])*(mid_p - coor[p]));
}
else{
force_sum += mass[p] / ((coor[p] - mid_p)*(coor[p] - mid_p));
}
}
if((force_sum<DIV && force_sum>=0) || (force_sum>DIV && force_sum<=0)){
balance_p = mid_p;
}
else{
if(force_sum>0){
right_p = mid_p;
find_balance();
}
else{
left_p = mid_p;
find_balance();
}
}
}

int main()
{
freopen("input.txt", "r", stdin);
T=10;
for(tc=1; tc<=T; tc++)
{
cin >> N;
for(int i=0; i<N; i++){
cin >> coor[i];
}
for(int i=0; i<N; i++){
cin >> mass[i];
}
cout << "#" << tc;
for(int i=0; i<N-1; i++){
left_p=coor[i];
right_p=coor[i+1];
find_balance();
printf(" %.10f", balance_p);
}
cout << endl;
}
return 0;
}
```