fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main
  5. {
  6. public static void main(String[] args) {
  7. Scanner in = new Scanner(System.in);
  8. PrintWriter out = new PrintWriter(System.out);
  9.  
  10. int n = in.nextInt();
  11. int r = in.nextInt();
  12. int sum = 0;
  13. double S;
  14. int[] x = new int[n];
  15. for (int i = 0; i < n; i++)
  16. x[i] = in.nextInt();
  17. for (int i = 0; i < n; i++)
  18. sum += x[i];
  19. S = Math.PI * r * r;
  20. for (int i = 0; i < n; i++)
  21. out.format("%.9f%n", (S / sum) * x[i]);
  22.  
  23. out.flush();
  24. }
  25. }
Success #stdin #stdout 0.07s 2184192KB
stdin
5 9
4 16 8 20 11
stdout
17.252135928
69.008543713
34.504271856
86.260679641
47.443373803