Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.LinkedList;
- import java.util.Queue;
- import java.util.Stack;
- class card_trick{
- public static int count(int N){
- Stack<Integer> sedum=new Stack<Integer>();
- Queue<Integer> spil=new LinkedList<Integer>();
- int Karta=1;
- int counter=0;
- while(Karta!=52)
- {
- spil.add(Karta++);
- }
- while(spil.peek()!=N)
- { counter++;
- for (int i=1;i<=7;i++)
- {
- sedum.push(spil.poll());
- }
- for (int i=1;i<=7;i++)
- {
- spil.add(sedum.pop());
- spil.add(spil.poll());
- }
- }
- return counter;
- }
- public static void main(String[] args) throws NumberFormatException, IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
- System.out.println(count(Integer.parseInt(br.readLine())));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement