上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 47 下一页
摘要: 知识点: 逆序遍历range:只需要[::-1]即可 (从头到尾切片,步长设置为-1) 代码 s=input() a,b=input().split() for i in range(len(s))[::-1]: if s[i]==a or s[i]==b: print("{} {}".format 阅读全文
posted @ 2022-05-29 09:24 kingwzun 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 方法一:使用list judge = [] for i in range(26): judge.append( chr(65+25-i) ) # print(judge) n= input() n= [judge[ord(i)-65] if 'A'<=i<='Z' else i for i in n 阅读全文
posted @ 2022-05-29 09:18 kingwzun 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 知识点 数据类型转化 代码 n=list(input())#string转list print(len(n),end= " ") n= map(int,n)#将list里面的元素转为int类型 ans=0 for i in n: ans+=i print(ans) 阅读全文
posted @ 2022-05-28 17:23 kingwzun 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 做法1:使用re.findall import re n=int(input()) k=input() cnt=format(n,"x") t=re.findall(k,cnt) print(len(t)) 做法2:朴素做法 n=int(input()) k=input() cnt=format(n 阅读全文
posted @ 2022-05-28 16:16 kingwzun 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 知识点: re正则表达式的使用‘ list转string string转数字 进制转化 代码: import re str=input() match = re.findall('[0-9a-fA-F]', str) str=''.join(match) str=str.lower() ans10= 阅读全文
posted @ 2022-05-28 11:40 kingwzun 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 知识点: 转化为指定长度的二进制 代码: import string a,b=map(int,input().split()) maxn=max(a,b) cnt1=list(format(a,"031b")) cnt2=list(format(b,"031b")) ans=0 for i in r 阅读全文
posted @ 2022-05-27 17:35 kingwzun 阅读(32) 评论(0) 推荐(0) 编辑
摘要: string转化为list cnt1=list(str) list转为string 命令: ''.join(list) 样例: list = [1, 2, 3, 4, 5] a=''.join(list) #结果即为:12345 b=','.join(list) #结果即为:1,2,3,4,5 进制 阅读全文
posted @ 2022-05-27 17:34 kingwzun 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 题目链接 原文 题意: 在点阵上,给出 N 个点的坐标(全部都是在格点上),将它们按顺序连接可以构成一个多边形,求该多边形内包含的格点的数目。 多边形的边不一定是水平或者竖直的,可以倾斜 题解: 首先由皮克定理$$ S = a + \frac{b}{2} - 1$$( S 是多边形面积,a 是多边形 阅读全文
posted @ 2022-05-27 10:31 kingwzun 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 知识点: ASCII码和字符的转化 转为字符chr(a) 转为ASCII码ord(c)) 代码: num=[eval(x) for x in input().split()] num.sort() for i in num[:-1]: print(chr(i),end="<") print(chr( 阅读全文
posted @ 2022-05-25 22:11 kingwzun 阅读(59) 评论(0) 推荐(0) 编辑
摘要: def gcd(a,b): if a%b == 0: return b else : return gcd(b,a%b) while 1: try: a, b = map(int, input().split()) ma=gcd(a,b) print("{} {}".format(ma,int(a* 阅读全文
posted @ 2022-05-25 21:30 kingwzun 阅读(192) 评论(0) 推荐(0) 编辑
上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 47 下一页