Advertisement
Guest User

G

a guest
Sep 15th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.*;
  3. public class EduA {
  4. public static void main(String []args){
  5. Scanner sc=new Scanner (System.in);
  6.  
  7.  
  8.  
  9. int n=sc.nextInt();
  10.  
  11.  
  12. int k=sc.nextInt();
  13.  
  14.  
  15.  
  16.  
  17. int[]a= new int[k];
  18.  
  19. boolean[]b= new boolean[600000+1];
  20.  
  21. int []index= new int[n+1];
  22.  
  23. for(int i=0;i<k;i++){
  24. a[i]=sc.nextInt();
  25. b[a[i]]=true;
  26. index[a[i]]=i;
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33. for(int i=1;i<n/2 +1;i++){
  34. if(b[i]&&b[i*2])
  35. {
  36. if(index[i]>index[2*i])
  37. System.out.println((index[i*2]+1)+" "+(index[i]+1));
  38. else
  39. System.out.println((index[i]+1)+" "+(index[2*i]+1));
  40. return;
  41. }
  42.  
  43. }
  44.  
  45. System.out.println(0+" "+0);
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement