1 Star 0 Fork 0

Awu-Miao/learn-z3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
3-calculate-distribution.py 460 Bytes
一键复制 编辑 原始数据 按行查看 历史
pwnfunction 提交于 2022-05-26 14:13 . added 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())
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Awu-Miao/learn-z3.git
[email protected]:Awu-Miao/learn-z3.git
Awu-Miao
learn-z3
learn-z3
main

搜索帮助