Geoffreylee 发表于 2020-3-19 11:20:59

def f_92(num: int):
    lst = []
    num_for_loop = num
    for i in :
      if num_for_loop >= i:
            lst.append(str(i))
            num_for_loop -= i

    return "+".join(lst)

print(f_92(155))

小贤啊哦 发表于 2020-5-6 10:47:51

def fun65(num):
    s=0
    a=[]
    while s<num:
      for i in range(8):
            s+=2**i
            a.append(2**i)
            if s==num:
               break
    print( '+'.join(str(i) for i in a))
fun65(255)

小陨aoq 发表于 2020-7-31 22:42:14

看看答案

Ilovecoding 发表于 2020-8-1 06:23:50

def fun(num):
    numbers =
    new_list = []
    if 1 <= num <= 255:
      for each_num in reversed(numbers):
            if num - each_num >= 0:
                new_list.append(each_num)
                num -= each_num
      result = " + ".join()
    return result

19971023 发表于 2020-8-7 09:50:00

1

BSOD 发表于 2020-8-9 13:53:07

# -*- coding:utf-8 -*-
# author: HPCM
# time: 2020/8/8 21:39
# file: test.py
from functools import lru_cache

# nums = 3
nums = int(input("请输入拆分的整数: "))

choice =
choice.sort()


@lru_cache()
def foo(num, i=-1):
    output_list = []
    use = choice
    y = num - use
    if y < 0:
      output_list += foo(num, i - 1)
    elif y == 0:
      output_list.append(str(use))
    else:
      output_list.append(str(use))
      output_list += (foo(y, i))
    return output_list


print("{} = {}".format(nums, " + ".join(foo(nums))))

风尘岁月 发表于 2020-8-9 14:12:42

{:10_285:}

aironeng 发表于 2020-12-8 09:04:24

学习

holiday_python 发表于 2021-4-14 18:00:15

看看
页: 1 2 3 4 [5]
查看完整版本: Python:每日一题 92(答题领鱼币)