fork download
  1. from sys import stdin
  2.  
  3. for line in stdin:
  4. n = int(line)
  5. res = None
  6.  
  7. for x in range(int(n**.5), 1, -1):
  8. if n >= x*x and n % x == 2:
  9. if n < x*x*x: res = x
  10. break
  11.  
  12. print(f"{n}: {res if res is not None else 'No solution'}")
Success #stdin #stdout 0.02s 9220KB
stdin
338
16
1000000
1
5
10
11
77
stdout
338: 16
16: No solution
1000000: 254
1: No solution
5: No solution
10: No solution
11: 3
77: 5