fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner s=new Scanner(System.in);
  13. List<Integer> arr=new ArrayList<>();
  14. int N=s.nextInt();
  15. int a[]={12,320,45,460,580};
  16. arr=solve(a,N,arr);
  17. System.out.println(arr);
  18. }
  19. public static List<Integer> solve(int[] A,int N,List<Integer> arr){
  20.  
  21. if(N==0){
  22. return arr;
  23. }
  24. if(A[N-1]%10==0){
  25. arr.add(A[N-1]);
  26. }
  27. return solve(A,N-1,arr);
  28. }
  29. }
Success #stdin #stdout 0.15s 56640KB
stdin
5
stdout
[580, 460, 320]