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;
- public class card_trick {
- public static int count(int N) {
- // Vasiot kod tuka
- int[] spil = new int[51];
- for (int i = 0; i < 51; i++) {
- spil[i] = i + 1;
- }
- int howMany = 0;
- while (true) {
- int[] firstSeven = new int[7];
- int[] secondSeven = new int[7];
- int[] novSpil = new int[51];
- for (int i = 6, j = 0; i >= 0; i--, j++) { //Prvite 7 vo obraten redosled
- firstSeven[j] = spil[i];
- }
- for (int i = 7, j = 0; i < 14; i++, j++) { //Vtorite 7 vo obicen redosled
- secondSeven[j] = spil[i];
- }
- for (int i = 14, j = 0; i < 51; i++, j++) { //Setiranje bez odozdole novite karti
- novSpil[j] = spil[i];
- }
- for (int i = 37, j = 0; i < 51; i++, j++) {
- novSpil[i] = secondSeven[j];
- i++;
- novSpil[i] = firstSeven[j];
- }
- howMany++;
- if (novSpil[0] == N)
- return howMany;
- for (int i = 0; i < 51; i++)
- spil[i] = novSpil[i];
- }
- }
- 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