You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
572 B
Python
36 lines
572 B
Python
3 years ago
|
with open('input', 'r') as f:
|
||
|
p_key_a = int(f.readline())
|
||
|
p_key_b = int(f.readline())
|
||
|
|
||
|
|
||
|
print(p_key_a, p_key_b)
|
||
|
|
||
|
PRIME = 20201227
|
||
|
SUBJECT_NUMBER = 7
|
||
|
|
||
|
|
||
|
def main():
|
||
|
enc_key = 1
|
||
|
|
||
|
loop_size_a = 0
|
||
|
print('Brute forcing loop size of a...')
|
||
|
while enc_key != p_key_b:
|
||
|
enc_key = loop(enc_key, SUBJECT_NUMBER)
|
||
|
loop_size_a += 1
|
||
|
|
||
|
enc_key = 1
|
||
|
print(loop_size_a)
|
||
|
for _ in range(loop_size_a):
|
||
|
enc_key = loop(enc_key, p_key_a)
|
||
|
|
||
|
print(enc_key)
|
||
|
|
||
|
pass
|
||
|
|
||
|
|
||
|
def loop(num, subj_num):
|
||
|
return (num * subj_num) % PRIME
|
||
|
|
||
|
|
||
|
main()
|