代码拉取完成,页面将自动刷新
3-calculate-distribution.py
#!/usr/bin/env python3
import z3
"""
Spend exactly 100 dollars and buy exactly 100 animals.
Dogs cost 15 dollars, cats cost 1 dollar, and mice cost 25 cents each.
You have to buy at least one of each. How many of each should you buy?
"""
d, c, m = z3.Ints('d c m')
solver = z3.Solver()
solver.add(1500 * d + 100 * c + 25 * m == 10000)
solver.add(d + c + m == 100)
solver.add(d >= 1, c >= 1, m >= 1)
if solver.check() == z3.sat:
print(solver.model())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。