2020-12-28 10:32:40 +03:00
|
|
|
def __main__():
|
|
|
|
let ordering = list()
|
|
|
|
ordering.append(0)
|
|
|
|
ordering.append(4) # 1 -> 4
|
|
|
|
ordering.append(10)# 2 -> 10
|
|
|
|
ordering.append(8) # 3 -> 8
|
|
|
|
ordering.append(7) # 4 -> 7
|
|
|
|
ordering.append(3) # 5 -> 3
|
|
|
|
ordering.append(2) # 6 -> 2
|
|
|
|
ordering.append(6) # 7 -> 6
|
|
|
|
ordering.append(9) # 8 -> 9
|
|
|
|
ordering.append(1) # 9 -> 1
|
|
|
|
ordering.extend(range(11,1000001))
|
|
|
|
ordering.append(5) # 1,000,000 -> 5
|
2021-01-04 17:33:43 +03:00
|
|
|
print("Done, ordering is", len(ordering))
|
2020-12-28 10:32:40 +03:00
|
|
|
|
2021-01-04 17:33:43 +03:00
|
|
|
print("Starting loop...")
|
2020-12-29 02:23:18 +03:00
|
|
|
#__builtins__.set_tracing("tracing=1")
|
2020-12-28 10:32:40 +03:00
|
|
|
|
|
|
|
let m0 = 5
|
|
|
|
let nx = 0
|
|
|
|
let px = 0
|
|
|
|
for i in range(0,10000000):
|
2020-12-29 02:23:18 +03:00
|
|
|
let m1 = ordering[m0]
|
|
|
|
let m2 = ordering[m1]
|
|
|
|
let m3 = ordering[m2]
|
2020-12-28 10:32:40 +03:00
|
|
|
ordering[m0] = ordering[m3]
|
|
|
|
nx = ((m0 + 999998) % 1000000) + 1
|
|
|
|
while (nx == m1) or (nx == m2) or (nx == m3):
|
|
|
|
nx = ((nx + 999998) % 1000000) + 1
|
|
|
|
px = ordering[nx]
|
|
|
|
ordering[nx] = m1
|
|
|
|
ordering[m3] = px
|
|
|
|
m0 = ordering[m0]
|
|
|
|
|
2022-06-29 07:55:21 +03:00
|
|
|
print(ordering[1]*ordering[ordering[1]])
|
2020-12-28 10:32:40 +03:00
|
|
|
|
|
|
|
__main__()
|