3-p03_monkey_peach五猴分桃

我只是一个虾纸丫 提交于 2020-02-22 02:59:42


def get_peaches(monkeys):
    peaches=1
    while not distribute(peaches,monkeys):
        peaches +=monkeys#每次加1太慢,可以每次加monkeys
    return peaches
def distribute(peaches,monkeys):
    for _ in range(monkeys):
         peaches -=1
         if peaches % monkeys !=0:
             return False
         peaches =peaches//monkeys * (monkeys-1)
    return True


if __name__ == '__main__':
    print(get_peaches(5))
D:\Anaconda\python.exe D:/AI20/06_codes/deeplearning_20/p03_monkey_peach.py
3121

Process finished with exit code 0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!