Skip to content

Instantly share code, notes, and snippets.

@ducnhse130201
Created December 16, 2018 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducnhse130201/90a7a77da2333e506ebb183c33aaf8c3 to your computer and use it in GitHub Desktop.
Save ducnhse130201/90a7a77da2333e506ebb183c33aaf8c3 to your computer and use it in GitHub Desktop.
matesS3R2(math_master.py)
from telnetlib import *
r = Telnet('125.235.240.166', 12346)
r.read_until('r = ')
r_ = int(r.read_until(' and ').strip(' and '))
r.read_until('p = ')
p = int(r.read_until('\n').strip())
def find_a_b_c(r,p):
arr = []
for i in range(r, p+1):
arr.append(i*i % p)
for i in range(len(arr)):
for j in range(len(arr)):
x = arr[i]
y = arr[j]
if x+y in arr:
a = i + r
b = j + r
c = arr.index(x+y) + r
return a,b,c
a,b,c = find_a_b_c(r_,p)
send_ = str(a) + ' ' + str(b) + ' ' + str(c)
r.write(send_ + '\n')
r.interact()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment