BetinaUKTC

zadacha3

Mar 24th, 2021 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package Prog;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scan = new Scanner(System.in);
  9. String [] input = scan.nextLine().split(" ");
  10. int arr[] = new int[input.length];
  11. for (int i = 0; i < input.length; i++) {
  12. arr[i] = Integer.parseInt(input[i]);
  13. }
  14. HashSet set = new HashSet<Integer>();
  15.  
  16. for(int k:arr){
  17. double value = Math.sqrt(k);
  18. if (value == (int) value) {
  19. set.add(k);
  20. }
  21. }
  22. List<Integer> result = new ArrayList<>(set);
  23. Collections.sort(result);
  24. Collections.reverse(result);
  25. System.out.println(result);
  26. }
  27. }
  28.  
Add Comment
Please, Sign In to add comment