阿be
阿be
全部文章
分类
题解(20)
归档
标签
去牛客网
登录
/
注册
阿be的博客
全部文章
(共22篇)
题解 | #质数因子#
把2的情况单独列出来,后面就只算奇数部分,但总感觉哪里有点问题 a=int(input()) while a%2==0: print(2,end=' ') a/=2 for i in range(3,int(a**0.5)+1,2): while a%i==0: ...
Python3
2022-04-05
0
309
题解 | #放苹果#
刚开始我还分了x>y、x<y、x=y三种情况,算重了好些个。最后发现其实已经分好类了,这种题思路还是要根据对立,找出最少的分类情况。 def zhong(x,y): if y==1 or x==1: # 一盘or一果 return 1 elif x<...
Python3
2022-04-04
0
266
题解 | #字符统计#
用字典做 num=input() num1=sorted(set(num)) dict1=dict.fromkeys(num1,0) ans='' for i in num: dict1[i]+=1 lst=sorted(dict1.items(),key=lambda x:x[1],rev...
Python3
2022-04-04
0
304
题解 | #统计大写字母个数#
递归做的,但是两层判断感觉有些麻烦,而且做的时候完全想不起来换行怎么换了:( def num(x): lst=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W...
Python3
2022-04-02
0
328
题解 | #尼科彻斯定理#
好像简单问题复杂化了。。。 a=int(input()) b=a**2 sum=[] if a%2==0: for i in range(1,a,2): sum.append(b-i) sum.append(b+i) else: for j in ra...
Python3
2022-04-02
0
250
题解 | #自守数#
想试试用i^2-i有多少个0来判断,但好像这种方法有点费时间。。。 import math n=int(input()) num=1 for i in range(1,n+1): n2=i**2 #该数的平方 len_i=int(math.log10(i))+1 #i的长度 ...
Python3
2022-04-01
0
206
题解 | #记负均正#
还是那个磨磨唧唧的我, 和我磨磨唧唧的代码 a=int(input()) b=list(map(int,input().split())) num1=0 num2=0 sum=0 for i in b: if i<0: num1+=1 #负整数数量 elif i...
Python3
2022-04-01
14
473
题解 | #字符串字符匹配#
请问各位兄弟姐妹这应该如何简化呀 a=set(input()) b=input() c=0 for i in a: if i in b: c+=1 if c==len(a): print('true') else: print('false')
Python3
2022-03-31
0
224
题解 | #整型数组合并#
宇宙第一麻烦解题 请问还有谁比我更饶舌麻烦:) a=input() lst=input().split() b=input() lst2=input().split() lst3=set(lst+lst2) lst3=list(map(int,lst3)) lst3.sort() lst3=l...
Python3
2022-03-31
0
226
题解 | #24点游戏算法#
学习大神思路然后再码一遍 def cal_24(s, res): if len(s) == 1: return s[0] == res for i in range(len(s)): mid = s[i] rest = s[:i] + ...
Python3
2022-03-11
15
2252
首页
上一页
1
2
3
下一页
末页