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