题解列表

筛选

统计2出现的次数(python简单方法)

摘要:解题思路:用for循环将数字已字符串的形式添加到列表中,用count函数统计2的数量参考代码:L, R = map(int, input().split()) num_list = [] for ……

python 线性筛法

摘要:解题思路:注意事项:参考代码:n=int(input()) ps=[True]*(n+1) p=[] for i in range(2,n+1):     if ps[i]:        ……

python来解一下

摘要:解题思路:while True: try: s=list(map(int,input().split())) n,m,items=s[0],s[1],s[2:] a=[i for……

选择排序python

摘要:解题思路:        选择排序的时间复杂度是O(n^2),其中n是待排序元素的数量。这是因为选择排序的基本操作是交换和比较,而每次交换和比较都需要遍历整个数组,因此时间复杂度为O(n^2)题意直接……

纸张尺寸(python硬核解法)

摘要:解题思路:给定了初始纸张的尺寸,后面按照思路一步一步来就行,直接看注释参考代码:import math    #因为题目要求向下取整,所以要导入math模块 p = list(input()) ……

阶乘(常规)

摘要:def f(n):     if n==1:         return 1     else:         return n*f(n-1) lst=[f(i) for i in

字符与ascll码值的转换

摘要:解题思路:注意事项:补充题解中Python代码空缺参考代码:print(ord("t"))print(chr(63))……

幂的末尾(python简单解法)

摘要:解题思路:这题很简单,直接看注释参考代码:a, b = map(int, input().split())x = (a ** b) % 1000    #要求a**b的末三位,所以取1000的余数if……

纪念品分组

摘要:W=int(input())n=int(input())lst=[]num=0for i in range(n):    lst.append(int(input()))lst.sort()while……