gen_tests.py (635B)
1 import os 2 3 # we want to be exhaustive in our search even though the heuristic is known. 4 def can_div(num): 5 for x in range(1,num+1): 6 for y in range(1,num+1): 7 if x%2 != 0 or y%2 != 0: 8 continue 9 if x + y == num: 10 return True 11 return False 12 13 14 for i in range(1,101): 15 in_file = str(i) + ".in" 16 out_file = str(i) + ".out" 17 18 with open(in_file, 'w') as in_file: 19 with open(out_file, 'w') as out_file: 20 in_file.write(str(i)) 21 st_write = "NO" 22 if can_div(i): 23 st_write = "YES" 24 out_file.write(st_write)