Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def rand():
- global x
- x = str(int(x) * int(x[3:]+x[:3]) // 1000 % 1000000)
- while len(x) < 6: x = '0' + x
- return int(x)
- for _ in range(int(input())):
- A = list(map(int, input().split()))
- B = A.copy()
- B.sort()
- N = len(A)
- x = '918255'
- T = 10000
- for t in range(T):
- for i in range(N):
- j = rand() % N
- A[i],A[j] = A[j],A[i]
- if A == B: break
- t += 1
- if t == T: t = -1
- print(t, ' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement