Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.LinkedList;
  5. import java.util.Queue;
  6. import java.util.Stack;
  7.  
  8.  
  9. class card_trick{
  10. public static int count(int N){
  11. Stack<Integer> sedum=new Stack<Integer>();
  12. Queue<Integer> spil=new LinkedList<Integer>();
  13. int Karta=1;
  14. int counter=0;
  15. while(Karta!=52)
  16. {
  17. spil.add(Karta++);
  18. }
  19. while(spil.peek()!=N)
  20. { counter++;
  21. for (int i=1;i<=7;i++)
  22. {
  23. sedum.push(spil.poll());
  24. }
  25. for (int i=1;i<=7;i++)
  26. {
  27. spil.add(sedum.pop());
  28. spil.add(spil.poll());
  29. }
  30. }
  31. return counter;
  32. }
  33. public static void main(String[] args) throws NumberFormatException, IOException {
  34. BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
  35. System.out.println(count(Integer.parseInt(br.readLine())));
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement