#include #include #include using namespace std; const int R = 150; int main() { double x0[16], y0[16], z0[16]; int q[16]; int alpha[8], beta[8]; for (int i = 0; i < 8; ++i) { cin >> alpha[i]; } for (int i = 0; i < 8; ++i) { cin >> beta[i]; } // Fill alpha ions for (int i = 0; i < 8; ++i) { int a = i / 4; int b = (i % 4) / 2; int c = i % 2; x0[i] = a / 2.0; y0[i] = b / 2.0; z0[i] = c / 2.0; q[i] = alpha[i]; } // Fill beta ions int beta_d[8] = {1, 1, 1, 1, 3, 3, 3, 3}; int beta_e[8] = {1, 1, 3, 3, 1, 1, 3, 3}; int beta_f[8] = {1, 3, 1, 3, 1, 3, 1, 3}; for (int i = 0; i < 8; ++i) { x0[8 + i] = beta_d[i] / 4.0; y0[8 + i] = beta_e[i] / 4.0; z0[8 + i] = beta_f[i] / 4.0; q[8 + i] = beta[i]; } double sum = 0.0; long long R_plus_2_sq = (long long)(R + 2) * (R + 2); long long R_sq = (long long)R * R; for (int nx = -R; nx <= R; ++nx) { long long nx2 = (long long)nx * nx; if (nx2 > R_plus_2_sq) continue; for (int ny = -R; ny <= R; ++ny) { long long ny2 = (long long)ny * ny; if (nx2 + ny2 > R_plus_2_sq) continue; for (int nz = -R; nz <= R; ++nz) { long long nz2 = (long long)nz * nz; if (nx2 + ny2 + nz2 > R_plus_2_sq) continue; for (int i = 0; i < 16; ++i) { double x = x0[i] + nx; double y = y0[i] + ny; double z = z0[i] + nz; double r2 = x*x + y*y + z*z; if (r2 < 1e-12) continue; if (r2 > R_sq + 1e-12) continue; sum += q[i] / sqrt(r2); } } } } cout << fixed << setprecision(10) << sum << endl; return 0; }