fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, r, sum = 0;
  8. double S;
  9. cin >> n >> r;
  10. int *x = new int[n];
  11. for (int i = 0; i < n; i++) cin >> x[i];
  12. for (int i = 0; i < n; i++) sum += x[i];
  13. S = M_PI * r * r;
  14. for (int i = 0; i < n; i++) cout << fixed << setprecision(9) << (S / sum) * x[i] << endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 15232KB
stdin
5 9
4 16 8 20 11
stdout
17.252135928
69.008543713
34.504271856
86.260679641
47.443373803