-1
import math

num_4s_and_5s = []

whetherBreak = 0

inputNum = input()

leftOver4 = int(inputNum) % 4
leftOver5 = int(inputNum) % 5

# append values if the leftover is 0 when divided by either 4
if leftOver4 == 0:
    num_4s_and_5s.append([(int(inputNum) / 4), 0])
else: whetherBreak += 1

# or 5
if leftOver5 == 0:
    num_4s_and_5s.append([0, (int(inputNum) / 5)])
else: whetherBreak += 1

# divide by 4, divide leftover by 5 and append the results if they make sense
for i in range(math.floor(int(inputNum) / 4) + 1):
    if (leftOver4 / 5) > 0 and isinstance((leftOver4 / 5), int) == True:
        num_4s_and_5s.append(
            [(math.floor(int(inputNum) / 4)), (leftOver4 / 5)])
    else: whetherBreak += 1

# And vice versa
for i in range(math.floor(int(inputNum) / 5) + 1):
    if (leftOver5 / 4) > 0 and isinstance((leftOver5 / 4), int) == True:
        num_4s_and_5s.append(
            [(leftOver5 / 4), (math.floor(int(inputNum) / 5))])
    else: whetherBreak += 1

# calculate and print the size of the 2d list
if whetherBreak == 4 or int(inputNum) == 6:
    print(0)
else: print(len(num_4s_and_5s) + 1)

我遇到了一个奇怪的错误,当我尝试运行此代码时,它说模数包含负值并且无法执行。总的来说,这是一个凌乱的代码,但我附上了下面的问题供您参考:


在此处输入图像描述

作为免责声明,我已经完成了比赛,我正在家里写这篇文章。

4

0 回答 0