Tags: programming python algorithm 

Rating:

```
from sympy import *
from pwn import *

def countPairs(G, L):
if L % G != 0:
return 0
if L == G:
return 1
n = L // G
return 1 << len(primefactors(n))

if __name__ == "__main__":
nc = remote('challs.xmas.htsp.ro', 6050)
for i in range(5):
chall = nc.recvline().decode().strip()
i = 0
while True:
test = nc.recvline().decode().strip()
print(test)
G = int(nc.recvline().decode().strip()[12:])
L = int(nc.recvline().decode().strip()[12:])
answer = countPairs(G, L)
nc.sendline(str(answer))
i += 1
if i == 100:
check = nc.recv().decode().strip()
print(check)
break
else:
check = nc.recvline().decode().strip()
print(check)
```
```
[x] Opening connection to challs.xmas.htsp.ro on port 6050
[x] Opening connection to challs.xmas.htsp.ro on port 6050: Trying 149.28.40.196
[+] Opening connection to challs.xmas.htsp.ro on port 6050: Done
Test number: 1/100
Good, that's right!
Test number: 2/100
Good, that's right!
Test number: 3/100
Good, that's right!
Test number: 4/100
Good, that's right!
Test number: 5/100
Good, that's right!
Test number: 6/100
Good, that's right!
Test number: 7/100
Good, that's right!
Test number: 8/100
Good, that's right!
...
...
...
Test number: 94/100
Good, that's right!
Test number: 95/100
Good, that's right!
Test number: 96/100
Good, that's right!
Test number: 97/100
Good, that's right!
Test number: 98/100
Good, that's right!
Test number: 99/100
Good, that's right!
Test number: 100/100
Good, that's right!
Wow, you really know this kind of weird math?
Here's your flag: X-MAS{gr347es7_c0mm0n_d1v1s0r_4nd_l345t_c0mmon_mult1pl3_4r3_1n73rc0nn3ct3d}
```
```
X-MAS{gr347es7_c0mm0n_d1v1s0r_4nd_l345t_c0mmon_mult1pl3_4r3_1n73rc0nn3ct3d}
```