自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(40)
  • 收藏
  • 关注

原创 并查集——可以解决最小生成树问题

# 并查集Set=list(range(n))def fun(x): if x!=Set[x]: Set[x]=find(Set[x]) return Set[x]

2022-01-20 17:18:39 223

原创 Pygame画板

import pygamefrom pygame.locals import *pygame.init()screen = pygame.display.set_mode((500, 500))pygame.display.set_caption("pygame画板")white = 255, 255, 255screen.fill(white)if_write = Falsespot_aggregate = []spot_amount = 0while True: for e

2021-06-28 22:17:22 191

原创 Python sympy练习

import sympy#表达式求值x=sympy.Symbol("x")y=sympy.Symbol("y")f=x**2+4*y+5result=f.evalf(subs={x:6,y:8})print(result)#方程求解x=sympy.Symbol("x")y=sympy.Symbol("y")f1=x+y-5f2=2*x-y+9print(sympy.solve([f1,f2],[x,y]))#数列求和n=sympy.Symbol('n')f=2*n+1prin

2021-06-27 11:30:50 194

原创 Python 图片隐写术

from PIL import Image"""取得一个 PIL 图像并且更改所有值为偶数使(最低有效位为 0)"""def makeImageEven(image): pixels = list(image.getdata()) # 得到一个这样的列表: [(r,g,b,t),(r,g,b,t)...] evenPixels = [(r >> 1 << 1, g >> 1 << 1, b >> 1 <<

2021-06-25 18:14:52 479

原创 Python+Pygame飞机大战(待完善)

import pygameimport timeimport sysimport randomfrom pygame.locals import *# 子弹类class Bullet(pygame.sprite.Sprite): def __init__(self): super().__init__() self.image = pygame.image.load("D:/bullets.png") width, height = s

2021-06-24 20:03:38 80

原创 python 基于共现分析赤壁人物关系

import jiebaimport matplotlib.pyplot as pltimport reimport string, collections, networkxSanguo = { '诸葛亮': ['诸葛孔明', '孔明', '卧龙'], '刘备': ['刘玄德', '皇叔', '刘皇叔', '玄德'], '孙权': ['孙仲谋', '仲谋'], '周瑜': ['周公瑾', '公瑾', '都督', '周都督'], '鲁肃': ['鲁子敬',

2021-06-22 11:37:03 256

原创 Python 实现简单的web服务

import osfrom http.server import BaseHTTPRequestHandler, HTTPServerclass ServerException(Exception): '''服务器内部错误''' passclass RequestHandler(BaseHTTPRequestHandler): Error_Page = """\ <html> <body> <p>Error&l

2021-06-21 12:25:10 332

原创 Python+Pygame实现2048

import pygame, sys, randomfrom pygame.locals import *white = 255, 255, 255blue = 0, 0, 200num = 5A = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]# 判断格子是否已满def fill(): t = 0 for i in range(4): for j in range(4):

2021-06-19 14:24:37 119

原创 python 初识类

import randomclass Dice: def __init__(self): self.face=None def roll(self): self.face = (random.randint(1, 6), random.randint(1, 6)) def total(self): return sum(self.face)d1=Dice()d1.roll()print(d1.face)print(d1.tot

2021-05-09 11:50:03 114

原创 python 动态规划

背包可容纳6kg水1kg,10刀书1kg,3刀食物2kg,9刀夹克2kg,5刀照相机1kg,6刀求能装下且总价值最大。A = [[0 for i in range(6)] for j in range(5)]W = {}W["book"] = [1, 3, 1]W["food"] = [2, 9, 2]W["jacket"] = [2, 5, 3]W["camer"] = [1, 6, 4]t = 0for i in range(6): if (i + 1 >= 3

2021-04-28 13:49:05 162

原创 python 贪心

描述:有五只老虎,1,2,3,4,5。要雇佣驯兽师,每个驯兽师只能驯服特定的老虎,要求雇佣的驯兽师最少,同时每只老虎都能有驯兽师。驯兽师1:1245驯兽师2:134驯兽师3:35驯兽师4:1245驯兽师5:1245a=set([1,2,3,4,5])t={}t[1]=set([1,2,4,5])t[2]=set([1,3,4])t[3]=set([3,5])t[4]=set([1,4,5])t[5]=set([4])s=[]while a: best=None c

2021-04-28 11:34:38 61

原创 python 队列+广度优先

from collections import dequesearch = deque()Q = {}Q["a"] = ["b", "c", "e"]Q["c"] = ["f"]Q["b"] = ["k"]Q["k"] = ["d"]Q["f"] = []Q["d"] = []Q["e"] = []search += Q["a"]def judge(t): return t == "d"while search: t = search.popleft() .

2021-04-23 22:53:07 73

原创 python 递归+快排

def quicksort(a): if (len(a) < 2): return a else: t = a[0] high = [] low = [] for i in range(1, len(a)): if (a[i] > t): high.append(a[i]) else: lo

2021-04-22 22:05:36 93

原创 python-优先序列的部分功能的实现(链式)

class PriorityNode: def __init__(self, data=None, priority=None, next=None): self.data = data self.priority = priority self.next = nextclass PriorityQueue: def __init__(self): self.front = None self.rear =

2021-03-28 16:26:45 86

原创 Python-顺序队列的部分功能的实现

class SqQueue(): def __init__(self, maxSize): self.maxSize = maxSize self.queueSlem = [None] * self.maxSize self.front = 0 self.rear = 0 def isEmpty(self): return self.rear == self.front def offer(self,

2021-03-26 11:43:51 97

原创 Python-顺序栈部分功能的实现和一个小练习

class SqStack: def __init__(self, maxSize): self.maxSize = maxSize self.stackElem = [None] * self.maxSize self.top = 0 def isEmpty(self): return self.top == 0 def push(self, x): if self.top == self.maxS

2021-03-25 21:16:08 99

原创 python反转单向链表——迭代法

class Node: def __init__(self, x): self.val = x self.next = Nonedef reverseList(head): prev = None while head: curr = head head = head.next curr.next = prev prev = curr return previf __n

2021-03-24 13:08:13 98

原创 双指针法的小练习

题目内容:输入一组数,如1,2,3,4,5输出一个数组,前部分全是偶数,后部分全是奇数。如2,4,1,3 ,54,2,3,1 ,5等等满足条件的均可。a = [int(x) for x in input().split()]i = 0j = len(a) - 1while i < j: while (i < j and a[i] % 2 == 0): i = i + 1 while (i < j and a[j] % 2 == 1):

2021-03-23 22:02:37 61

原创 python if-elif两种实现方法

import timedef fun(n): if n == "1": return 1 elif n == "2": return 2 elif n == "3": return 3 elif n == "4": return 4 else: return 5s = input()start = time.time()t = 0for i in range(len(s)):

2021-02-07 17:37:11 313 1

原创 Python-ural1260. Nudnik Photographer

Nudnik Photographer问题链接n = int(input())a = []a.append(1)a.append(1)a.append(2)if (n > 3): for i in range(n - 3): a.append(a[i + 2] + a[i] + 1)print(a[n - 1])最初想用全排列,不出所料时间超了。

2021-02-05 09:55:50 143 1

原创 K-means聚类算法的小例子

给定一个二维的数据集,要求化为2个类别。点 x y1 0 02 1 13 5 5 4 5 65 2 0文件内容(路径:D:\name.txt)1,0,02,1,13,5,54,5,65,2,0代码段:from sklearn.cluster import KMeansdef loadData(filePath): fr = open(filePath, 'r+') lines = fr.readlines() retData

2021-02-03 10:38:07 677 2

原创 Python-ural1026. Questions and Answers

Questions and Answers问题链接n = int(input())a = []for i in range(n): a.append(int(input()))s = input()m = int(input())b = []for i in range(m): b.append(int(input()))a.sort()for i in range(m): print(a[b[i] - 1])

2021-02-02 17:27:34 118 1

原创 华为申请暑期实习的建议——软件开发

如果你毕业想去华为工作,如果你想先体验下企业的生活,都可以在大三尝试申请华为实习生,想知道具体过程可以直接搜“华为校招”,有比较详细的过程介绍,我在这里想说几个自己从中的体会和建议。1.项目经历>else无论是技术面还是主管面,都会问做过的项目,50%+的时间都在谈项目,这个项目不一定是和老师做的什么大项目,自己开发的app,小游戏,能展示出来的就行,没有的话一定要自己找几个做做,不要直接copy。2.现场编程并不难基本上大学只要学了c/c++基础课程,都可以编出来,不用太担心。3.准备好答

2020-07-12 16:49:05 1214

原创 Python-ural1021. Sacrament of the Sum

Sacrament of the Sum具体题目请点击我查看a=int(input())A=[]for i in range(a): A.append(10000-int(input()))A.sort()b=int(input())B=[]for i in range(b): B.append(int(input()))B.sort()if(set(A) & set(B)==set()): print("NO")else: print("YES

2020-05-19 10:57:15 152

原创 Python-ural1014. Product of Digits

Product of Digits具体题目请点击我查看``n=int(input())A=[]s=0if(n==0): print(10)else: while(n>=10): f=0 for i in range(2,10): if(n%(11-i)==0): n=int(n/(11-i)) A.append((11-i))

2020-05-18 16:47:39 125

原创 Python-ural2111. Plato

Plato具体题目请点击我查看n=int(input())a=[int(x) for x in input().split()]s=0a.sort()m=sum(a)for i in range(n): s=s+m*a[i] m=m-a[i] s=s+m*a[i]print(s)选取任意的方案,结果都相同。

2020-05-18 15:43:31 134

原创 Python-ural1296. Hyperjump

Hyperjump具体题目请点击我查看n=int(input())A=[]m=0maxx=0for i in range(n): A.append(int(input()))for i in range(n): m=m+A[i] if(m<=0): m=0 if(m>maxx): maxx=mprint(maxx)

2020-05-17 09:42:38 355

原创 Python-ural1336. Problem of Ben Betsalel

Problem of Ben Betsalel具体题目请点击我查看AC:n=int(input())print(n**2)print(n)超时:import mathn=int(input())for i in range(1,n+1): s=n*i if(math.sqrt(s)==int(math.sqrt(s))): print(i*int...

2020-04-10 16:49:37 98

原创 Python-ural1225. Flags

Flags具体题目请点击我查看n=int(input())a=[0]*45a[0]=2a[1]=2for i in range(2,45): a[i]=a[i-1]+a[i-2]print(a[n-1])就是求兔子数列。n种排列=n-1种(+红或白,取决于n-1的最后的颜色)+n-2种(+蓝红或蓝白,同理)...

2020-04-07 17:48:27 115

原创 Python-ural1079. Maximum

Maximum具体题目请点击我查看c=[]while(1): a = [0, 1] n = int(input()) if(n!=0): for i in range(1, n + 1): a.append(a[i]) a.append(a[i] + a[i + 1]) b = a[0:n...

2020-04-01 16:54:28 99

原创 Python-ural1123. Salary

Salary具体题目请点击我查看n=input()if(len(n)==1): print(n)else: s = int(n) a = n[0:int(len(n) / 2)] b = n[int((len(n) + 1) / 2):len(n)] x1 = a + b a0 = a[::-1] x2 = a + a0 if...

2020-03-30 18:26:14 205

原创 Python-Ural2069. Hard Rock

Hard Rock具体题目请点击我查看n = list(map(int,input().split()))a=n[0]b=n[1]A=[]def f(x): t=0 for i in range(len(x)): t=t+x[i] return tfor i in range(a): s=int(input()) A.appen...

2020-03-27 11:56:51 118

原创 Python-ural1796. Amusement Park

Amusement Park具体题目请点击我查看num = list(map(int,input().split()))a=num[:]n=int(input())s1=num[0]*10+num[1]*50+num[2]*100+num[3]*500+num[4]*1000+num[5]*5000for i in range(6): if(a[i]!=0): ...

2020-03-22 19:01:01 161

原创 Python-ural2115. The Knowledge Day

The Knowledge Day具体题目请点击我查看n=int(input())num = list(map(int,input().split()))a=num[:]b=num[:]a.sort()#正序b.sort()b.reverse()#倒序if(num==a or num==b): print("Nothing to do here")else: t...

2020-03-20 17:04:01 159

原创 Python-ural1573. Alchemy

1573.Alchemy具体题目请点击我查看num=list(map(int, input().strip().split()))n=int(input())t=1for i in range(n): s=input() if(s[0]=="R"): t=t*num[1] elif(s[0]=="Y"): t=t*num[2] ...

2020-03-19 13:50:03 97

原创 Python-ural1446. Sorting Hat

Sorting Hat具体题目请点击我查看n=int(input())a=[]b=[]c=[]d=[]for i in range(n): s1=input() s2=input() if(s2=="Slytherin"): a.append(s1) elif(s2=="Hufflepuff"): b.append(s1...

2020-03-18 16:43:47 100

原创 Python-ural1792. Hamming Code

Hamming Code具体题目请点击我查看num=list(map(int, input().strip().split()))def f1(num): a1= (num[1] + num[2] + num[3]) % 2 a2 = (num[2] + num[0] + num[3]) % 2 a3 = (num[1] + num[3] + num[0]) % 2...

2020-03-16 12:39:37 166

原创 Python-ural2068. Game of Nuts

Game of Nuts具体题目请点击我查看n=int(input())num=list(map(int, input().strip().split()))s=0t=1for i in range(n): if(t==1): if(num[i]%4==3): t=0 else: t=1 e...

2020-03-15 22:37:03 134

原创 Python-ural1712. Cipher Grille

Cipher Grille具体题目请点击我查看`a=[[0 for i in range(4)]for i in range(4)]b=[]def f1(a):#输入一个二维数组,将其顺时针旋转 m=[[0 for i in range(4)]for i in range(4)] for i in range(4): for j in range(4): ...

2020-03-15 17:03:01 127

原创 Python-ural2023. Donald is a postman

Donald is a postman具体题目请点击我查看n=int(input())a=[0]for i in range(n):s=input()if(s[0]“A” or s[0]“P” or s[0]“O” or s[0]“R”):a.append(0)elif(s[0]“B” or s[0]“M” or s[0]==“S”):a.append(1)else:a.ap...

2020-03-12 21:13:56 140

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除