Advertisement
Guest User

Untitled

a guest
May 6th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import java.io.IOException;
  2.  
  3. import java.text.DecimalFormat;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import java.util.Locale;
  7. import java.util.Scanner;
  8.  
  9. public class Main {
  10.  
  11. public static void main(String[] args) throws IOException {
  12. // TODO Auto-generated method stub
  13. Locale.setDefault(Locale.US);
  14. Scanner sc = new Scanner(System.in);
  15.  
  16. int N = sc.nextInt();
  17. List<Boolean> lista = new ArrayList<Boolean>();
  18. int times = 1048575;
  19. for (int j = 0; j < times; j++) {
  20. lista.add(false);
  21. }
  22.  
  23. for (int i = 0; i < N; i++) {
  24.  
  25. int D = sc.nextInt();
  26. int I = sc.nextInt();
  27.  
  28.  
  29. List<Boolean> list = new ArrayList<Boolean>(lista);
  30.  
  31.  
  32.  
  33.  
  34. int iterator = 1;
  35.  
  36.  
  37. for (int j = 0; j < I; j++) {
  38. iterator = 1;
  39.  
  40. for (int j2 = 0; j2 < D; j2++) {
  41. boolean temp = list.get(iterator-1);
  42. list.set(iterator-1, !temp);
  43. if(j2 < D - 1){
  44. if(temp){
  45. iterator = 2 * iterator + 1;
  46. }else{
  47. iterator = (2 * iterator);
  48. }
  49. }
  50.  
  51.  
  52. }
  53. }
  54.  
  55. System.out.println(iterator);
  56.  
  57.  
  58. }
  59.  
  60. sc.nextInt();
  61.  
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement