t | from random import choice | t | from random import choice |
| | | |
| def divrandom(a, b, s, p): | | def divrandom(a, b, s, p): |
| n = 0 | | n = 0 |
| if a > b: | | if a > b: |
| a, b = (b, a) | | a, b = (b, a) |
| for i in range(a, b + 1, s): | | for i in range(a, b + 1, s): |
| if i % p != 0: | | if i % p != 0: |
| n += 1 | | n += 1 |
| if n != 0: | | if n != 0: |
| break | | break |
| if n == 0: | | if n == 0: |
| return n | | return n |
| r = choice(range(a, b + 1, s)) | | r = choice(range(a, b + 1, s)) |
| while r % p == 0: | | while r % p == 0: |
| r = choice(range(a, b + 1, s)) | | r = choice(range(a, b + 1, s)) |
| return r | | return r |