脚踝动了手术,现在宾馆恢复,伤筋动骨一百天还真不是说笑的,继续努力吧。
文章目录
- 靠谱的车
- 灰度图恢复
- 灰度图恢复 -- for循环使用例子
靠谱的车
https://www.nowcoder.com/discuss/564514429228834816
这个题目思路不难,就是要自己学会看代码,gpt也不可能一次就吐出代码,还是要学会改
另外动态规划可以缩短时间,但你不给我答案我还真不会做,或者得慢慢来,很逆天。
def replace_4_with_5(num):result = 0multiplier = 1while num > 0:digit = num % 10if digit == 4:digit = 5result += digit * multipliermultiplier *= 10num //= 10return resultdef calculate_actual_mileage(meter_reading):# meter_readingstart = 0count = 0while True:start += 1count += 1# 如果start含有4,则该位数进1,start = replace_4_with_5(start)if start == meter_reading:breakreturn countif __name__ == "__main__":meter_reading = int(input("请输入计费表读数:"))actual_mileage = calculate_actual_mileage(meter_reading)print("实际里程数为:", actual_mileage)
灰度图恢复
https://www.nowcoder.com/discuss/565217974919901184
灰度图恢复 – for循环使用例子
https://www.nowcoder.com/discuss/565217974919901184
for循环两两引用的方法if __name__ == "__main__":# 获取用户输入# user_input = input("请输入一串用空格隔开的数字:")# 将输入字符串按空格分割成列表# number_strings = user_input.split()# 将字符串列表转换为整数列表# numbers = [int(num) for num in number_strings]# 如果需要浮点数,可以使用以下代码:# numbers = [float(num) for num in number_strings]numbers = [10, 10, 56, 34, 99, 1, 87, 8, 99, 3, 255, 6, 99, 5, 255, 4, 99, 7, 255, 2, 99, 9, 255, 21]# 输出结果print("你输入的数字是:", numbers)number1 = numbers[2:]for i in range(len(number1)):value = number1[i]number = number1[i+1]print(value,number)print(len(numbers) - 2)
if __name__ == "__main__":# 获取用户输入numbers = input("请输入一串用空格隔开的数字:")special_number = input("具体像素位置:")# 将输入字符串按空格分割成列表number_strings = numbers.split()special_number = special_number.split()# 将字符串列表转换为整数列表numbers = [int(num) for num in number_strings]special_number = [int(num) for num in special_number]a = special_number[0]b = special_number[1]# 如果需要浮点数,可以使用以下代码:# numbers = [float(num) for num in number_strings]# numbers = [10, 10, 56, 34, 99, 1, 87, 8, 99, 3, 255, 6, 99, 5, 255, 4, 99, 7, 255, 2, 99, 9, 255, 21]# 输出结果print("你输入的数字是:", numbers)row = numbers[0]col = numbers[1]number1 = numbers[2:]grayscale = []for i in range(int(len(number1) / 2)):# print(i) 0 ~ 21value = number1[2 * i]number = number1[2 * i+1]for j in range(number):grayscale.append(value)print(len(grayscale))print(grayscale[col * a + b])