fork 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++)
  12. cin >> x[i];
  13. for (int i = 0; i < n; i++)
  14. sum += x[i];
  15. S = M_PI * r * r;
  16. for (int i = 0; i < n; i++)
  17. cout << fixed << setprecision(9) << (S / sum) * x[i] << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 15232KB
stdin
5 9
4 16 8 20 11
stdout
17.252135928
69.008543713
34.504271856
86.260679641
47.443373803