![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
蓝桥杯刷题打卡
星游野!
这个作者很懒,什么都没留下…
展开
-
蓝桥杯算法训练(1-20)
印章n, m = map(int, input().split())def quick_multi(n, m): res = 1 while m > 0: if m & 1: res *= n n *= n m = m >> 1 return resdef compose_dp(num): dp_comb = [[1 for i in range(num + 1)] f原创 2022-01-20 11:13:58 · 405 阅读 · 0 评论 -
力扣数据结构入门第9天打卡
20有效括号:def isValid(self,s): if len(s) % 2 == 1: return False pairs = { ")": "(", "]": "[", "}": "{", } stack = list() for ch in s: if ch in pairs:原创 2021-12-07 19:55:31 · 146 阅读 · 0 评论 -
力扣数据结构入门打卡第8天
206反转链表def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ if(head==None or head.next==None): return head newhead=self.reverseList(head.next) head.next.next=head h原创 2021-12-06 20:44:56 · 126 阅读 · 0 评论 -
力扣数据结构入门第7天打卡
141环形链表:def hasCycle(self, head): """ :type head: ListNode :rtype: bool """ n=head x=0 if n==None: return False while n.next!=None: n=n.next x+=1原创 2021-12-05 20:17:09 · 518 阅读 · 0 评论 -
力扣数据结构入门第6天
387字符串中的第一个唯一字符串def firstUniqChar(self, s): """ :type s: str :rtype: int """ if len(s)<=1: return 0 temp=[] for i in range(len(s)): if s[i] in temp: conti原创 2021-12-04 21:17:21 · 63 阅读 · 0 评论 -
力扣数据结构入门第5天打卡
36有效数独 def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ row = [set() for _ in range(9)] col = [set() for _ in range(9)] palace = [[set() for _ in range(3)] for _原创 2021-12-04 20:21:22 · 86 阅读 · 0 评论 -
力扣数据结构入门第4天打卡
566重塑矩阵 def matrixReshape(self, mat, r, c): """ :type mat: List[List[int]] :type r: int :type c: int :rtype: List[List[int]] """ temp=[] for i in range(len(mat)): for j in r原创 2021-12-04 20:04:15 · 219 阅读 · 0 评论 -
力扣数据结构入门第3天打卡
350.两个数组的交集:def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ res=[] if len(nums1)>len(nums2): for i in nums2:原创 2021-12-02 20:49:28 · 423 阅读 · 0 评论 -
力扣数据结构入门第2天打卡(今天的题有点水)
原创 2021-11-30 17:27:19 · 153 阅读 · 0 评论 -
力扣数据结构入门第1天打卡
217 存在重复元素def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ have = [] for i in range(len(nums)): if nums[i] not in have: have.append(nums[i])原创 2021-11-29 18:21:54 · 222 阅读 · 0 评论 -
PAT打卡1019-1022
1019(要注意为6174的输入)number = input()i=0while (number!='6174' and number!='0000') or i==0: while len(number)<4: number='0'+number number = [int(i) for i in number] front = sorted(number, reverse=True) behind = sorted(number)原创 2021-11-25 16:44:48 · 158 阅读 · 0 评论 -
PAT打卡1017-1018
1017(20/20):A,B=input().split(" ")b=int(B)a=int(A)q=a//br=a-q*bprint(q,end=" ")print(r,end="")1018(20/20)(if语句多了要注意elif、if、else的逻辑区别)n = input()n = int(n)ping = 0jiasheng = 0yisheng = 0jiac = 0jiaj = 0jiab = 0yic = 0yij = 0yib = 0f原创 2021-11-24 21:11:29 · 181 阅读 · 0 评论 -
PAT打卡1013-1016
1013(注意这个题是令Pi表示第i个素数。现任给两个正整数M≤N≤10^4,请输出PM到 PN的所有素数,这里的M,N表示的是第几个素数,所以区间要开大一点哟,本人取(2,1000000))(20/20)import mathdef primes_check(number): if number > 1: if number == 2: return True if number % 2 == 0: ...原创 2021-11-22 21:37:04 · 198 阅读 · 0 评论 -
PAT打卡1011-1012
1011n=input()n=int(n)for i in range(n): num=[] num=input().split(" ") num=[int(num[j]) for j in range(len(num))] if num[0]+num[1]>num[2]: print('Case #{}: true'.format(i+1)) else: print('Case #{}: false'.format(i+1原创 2021-11-21 21:11:03 · 594 阅读 · 0 评论 -
PAT打卡1008-1010
不得不说,你们是龙1008(2,3非零返回值,1答案错误)nums=input().split()num=int(nums[0])n=int(nums[1])data=input().split()array=[int(data[i]) for i in range(num)]def func(t,n): for i in t[-n:]: print(i,end=" ") for i in t[:-n]: if i ==t[:-n][-1]原创 2021-11-21 00:43:41 · 225 阅读 · 0 评论 -
PAT打卡1005-1007
1005:20/25的代码(服了)n=int(input())lists=[]lists=input().split(" ")lists=[int(lists[i]) for i in range(n)]res=[]for j in range(len(lists)): t=lists[j] if t in res: continue while t!=1: if t%2==0: t/=2原创 2021-11-19 19:58:25 · 298 阅读 · 0 评论 -
PAT打卡1001-1004
开始针对蓝桥杯进行算法训练这是过去两天的任务记录,开始上手时难度较低,对于平台的提交使用模式做一下记录,对题目做一下简要分析:1001:不做分析1002:n = int(input())sum = 0#求和while n>=1: sum += n%10 n = n // 10sum_list = []#分列while sum>=1: sum_list.append(sum%10) sum = sum // 10sum_list.原创 2021-11-19 17:03:42 · 192 阅读 · 0 评论