海洋游人
海洋游人
全部文章
分类
归档
标签
去牛客网
登录
/
注册
海洋游人的博客
全部文章
(共29篇)
题解 | 单词倒排
s = input() # 本题用re包内的re.sub()函数可以很好地解决。 import re s_new = re.sub(r'[$*!#]', r' ', s) s_res_list = list(s_new.split())[::-1] # [::-1] 可以将list反转。 p...
2025-04-09
0
26
题解 | 质数因子
n = int(input()) prime_factor_list = [] """ Important Notes: 1. We iterate from 2 to (square root of n)+1 because we do not need to ...
2025-04-09
0
18
题解 | 字符串分隔
s = input() # Add zeros at the end of the input string if its length is not a multiple of 8: s_length = len(s) if s_length%8 == 0: pass else: ...
2025-04-09
0
26
题解 | 合并表记录
n_records = int(input()) res_dic = {} for i in range(n_records): key, value = map(int, input().split()) if key not in res_dic: res_di...
2025-04-08
0
27
题解 | 记票统计
n_cands = int(input()) cand_list = list(input().split()) m_voters = int(input()) vote_res = list(input().split()) # Use the candidate list to create ...
2025-04-08
0
25
题解 | 表示数字
s = input() import re s_new = re.sub(r'[0-9]+', r'*\g<0>*', s) print(s_new)
2025-04-08
0
19
题解 | 杨辉三角的变形
""" The key here is to realize that the answer follows a pattern of '2 3 2 4' after n = 2. """ n = int(input()) if n &...
2025-04-08
0
21
题解 | 整型数组合并
# 这道题用set解决是最佳方案。 n = int(input()) n_list = map(int, input().split()) m = int(input()) m_list = map(int, input().split()) n_set = set(n_list) # set()...
2025-04-08
0
17
题解 | 删除字符串中出现次数最少的字符
s = input() dic = {} # Initialize a dictionary to count the occurrence of the letters. for char in s: if char not in dic: dic[char] = 1 ...
2025-04-08
0
21
题解 | 自守数
n = int(input()) num_count = 0 for i in range(n+1): i_str = str(i) tar_length = len(i_str) i_sqr = i**2 i_sqr_str = str(i_sqr) i...
2025-04-08
0
25
首页
上一页
1
2
3
下一页
末页