diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..a57fde5 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0d33757 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f1bdbf1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/mycode.iml b/.idea/mycode.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/mycode.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ACM/DongDong认亲戚.py b/ACM/DongDong认亲戚.py new file mode 100644 index 0000000..f28dfbf --- /dev/null +++ b/ACM/DongDong认亲戚.py @@ -0,0 +1,2 @@ +a=[0]*int(2e4) +print(len(a)) \ No newline at end of file diff --git a/ACM/World Finals.py b/ACM/World Finals.py new file mode 100644 index 0000000..70c2a32 --- /dev/null +++ b/ACM/World Finals.py @@ -0,0 +1,54 @@ +from functools import cmp_to_key +c=[[],[]] +string=[[],[]] +for i in range(2): + a = eval(input()) + while a>0: + s=input().split() + s[1],s[2]=eval(s[1]),eval(s[2]) + c[i].append(s) + string[i].append(s[0]) + a-=1 +def cmp(a,b): + if a[1]>b[1]: + return -1 + elif a[1]==b[1]: + if a[2]n:continue; + nums.append([m,n]) +def cmp(a,b):#升序 + if(a[0]>b[0]): + return 1 + else : + return -1#不变 +nums=sorted(nums,key=functools.cmp_to_key(cmp)) +# for i in nums: +# print(i) +sum = 0 +start,end=nums[0][0],nums[0][1] +count=1 +while count=start and nums[count][0]<=end: + if end<=nums[count][1]: + end=nums[count][1] + else : + sum+=end-start+1 + start=nums[count][0];end=nums[count][1] + count+=1 +sum+=end-start+1 +print(a-sum+1) \ No newline at end of file diff --git a/ACM/校门外的树.py b/ACM/校门外的树.py new file mode 100644 index 0000000..b9b44d6 --- /dev/null +++ b/ACM/校门外的树.py @@ -0,0 +1,7 @@ +a,b =map(int, input().split(' ')) +nums=[] +for i in range(b): + m,n=map(int,input().split(' ')) + nums.extend(range(m,n+1)) +nums=set(nums) +print(a+1-len(nums)) \ No newline at end of file diff --git a/盘荣博/README.md b/盘荣博/README.md new file mode 100644 index 0000000..3ff7495 --- /dev/null +++ b/盘荣博/README.md @@ -0,0 +1,7 @@ +**三个文件夹** + +数据可视化:暂时没有文件。 + +图:其中包括最短路径和最小生成树的展示 + +线性规划: 使用scipy库,便且使用scipy的optimize模块下的linprog函数,numpy函数统一操作数据以及使用matplotlib库下的pyplot模块 \ No newline at end of file diff --git a/盘荣博/数据可视化/week1.py b/盘荣博/数据可视化/week1.py index e69de29..12f7640 100644 --- a/盘荣博/数据可视化/week1.py +++ b/盘荣博/数据可视化/week1.py @@ -0,0 +1,9 @@ +import pandas as pd +import matplotlib.pyplot as plt +df = pd.read_excel("棉花产量论文作业的数据.xlsx") +plt.plot(df["年份"],df["单产"]) +plt.rcParams['font.sans-serif']="SimHei" +plt.ylabel('单产') +plt.xlabel('年份') +plt.show() +print(df) \ No newline at end of file diff --git a/盘荣博/数据可视化/棉花产量论文作业的数据.xlsx b/盘荣博/数据可视化/棉花产量论文作业的数据.xlsx new file mode 100644 index 0000000..162f47d Binary files /dev/null and b/盘荣博/数据可视化/棉花产量论文作业的数据.xlsx differ diff --git a/盘荣博/线性规划/插值和拟合/inter.py b/盘荣博/线性规划/插值和拟合/inter.py new file mode 100644 index 0000000..4ec6517 --- /dev/null +++ b/盘荣博/线性规划/插值和拟合/inter.py @@ -0,0 +1,16 @@ +import numpy as np +import pylab as pl +from scipy import interpolate +import matplotlib.pyplot as plt +x = np.linspace(0,2*np.pi+np.pi/4,10) +x1 = np.linspace(0,2*np.pi+np.pi/4,100)#num个0~2*Pi+Pi/4的范围的点 +y = np.sin(x) +y1= np.sin(x1) +plt.xlabel(f"安培/A") +plt.ylabel(f'伏特/V') +linear_ = interpolate.interp1d(x,y) +print(linear_(x1)) +plt.rcParams['font.sans-serif'] = ['SimSun']#设置字体 +plt.plot(x,y,'o',label=f"原始数据") +plt.plot(x1,linear_(x1),"*",label="线性插入") +pl.show() \ No newline at end of file diff --git a/盘荣博/线性规划/插值和拟合/test1.py b/盘荣博/线性规划/插值和拟合/test1.py new file mode 100644 index 0000000..542cc88 --- /dev/null +++ b/盘荣博/线性规划/插值和拟合/test1.py @@ -0,0 +1,27 @@ +from scipy import optimize +import numpy as np + +c= np.array([-1,4]) +A=np.array([[-3,1],[1,2]]) +b=np.array([6,4])#小于关系 +Aeq=np.array([[1,1,1]])#相等 +beq = np.array([7])# +bounds = ((None,None),(-3,None)) +res = optimize.linprog(c,A,b,None,None,bounds=bounds) +print("目标函数最小值:",res.fun)#目标函数最优解 +print("最优解",res.x)#求得的最优解 + + +c = [-1,2,3] +A=[[-2,1,1],[3,-1,-2]] +b=[[9],[-4]] +Aeq =[[4,-2,-1]] +beq=[-6] +LB=[-10,0,None] +UB = [None]*len(c) +print(UB) +bound = tuple(zip(LB,UB)) +print(zip(LB,UB),'\n',bound) +res = optimize.linprog(c,A,b,Aeq,beq,bounds=bound) +print("函数的最小值为",res.fun) +print("最优解为:",res.x) \ No newline at end of file