Compare commits

..

4 Commits

Author SHA1 Message Date
JCHPJP c946a92701 修改
1 year ago
JCHPJP 2b2079026a 修改
1 year ago
JCHPJP 321434f837 Merge remote-tracking branch 'origin/盘荣博' into 盘荣博
1 year ago
JCHPJP 8b36d3da1b acm
1 year ago

@ -1,2 +0,0 @@
a=[0]*int(2e4)
print(len(a))

@ -1,54 +0,0 @@
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]<b[2] :
return -1
else:
return 1
else :
return 1
c[0]=sorted(c[0],key=cmp_to_key(cmp))
# print(c[0])
c[1]=sorted(c[1],key=cmp_to_key(cmp))
# print(c[1])
# m='123'
# n='123'
# print(m==n)
st="lzr010506"
s=set(string[0])&set(string[1])
# for i in c[0]:
# for j in c[1]:
# if i[0] == j[0] :
# s.append(j[0])
# print(s)
ans1=0
ans2=0
i=0
while c[0][i][0] != st:
# print(c[0][i][0])
if c[0][i][0] in s:
ans1+=1
i+=1
ans1= i+1-ans1
i=0
while c[1][i][0]!=st:
# print(c[1][i][0])
if c[1][i][0] in s:
ans2+=1
i+=1
ans2=i+1-ans2
# print(ans1,ans2)
print(min(ans1,ans2))
# print(c[0],'\n',c[1])

@ -1,18 +0,0 @@
import heapq
import ctypes
a=int(input())
b=input().split()
for i in range(len(b)):
b[i]=int(b[i])
heapq.heapify(b)
# print(b)
sum=0
while len(b) != 1:
c,d=heapq.nsmallest(2,b)
# heapq.heappop(b)
# heapq.heappop(b)
b.remove(c)
b.remove(d)
sum+=c+d
heapq.heappush(b,c+d)
print(sum)

@ -1,28 +0,0 @@
import functools
a,b =map(int, input().split(' '))
nums=[]
for i in range(b):
m,n=map(int,input().split(' '))
if m>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<len(nums):
if nums[count][0]>=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)

@ -1,7 +0,0 @@
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))

@ -1,64 +0,0 @@
%AHP步骤
clc,clear,close all;
A=[1,2,3,5
1/2,1,1/2,2
1/3,2,1,2
1/5,1/2,1/2,1];
[row,col]=size(A);
%判断矩阵一致性检验
n=col;
maxlam=max(eig(A));
RI=[0 0 0.58 0.90 1.12 1.24 1.32 1.41 1.45];
CI=(maxlam-n)/(n-1);
CR=CI/RI(n);
%判断矩阵确定权重
for i=1:col
sumcol=sum(A(:,i));
for j=1:row
A(j,i)=A(j,i)/sumcol;
end
end
weig=zeros(row,1);
for i=1:row
sumrow=sum(A(i,:));
weig(i)=sumrow/n;
end
%各个指标归一化 按列单位化
data= [1686.4 3183 12000 397
903.6 1916.4 3439.6 43
837.6 817.6 4748 1159
824.9 1296.4 12000 442
2110.2 1465.7 6199.5 228];
[rowd,cold]=size(data);
for i=1:cold
sumcold=sum(data(:,i));
for j=1:rowd
data(j,i)=data(j,i)/sumcold;
end
end
%按权重计算分数
score=data*weig;
projectNames={'老番茄','何同学','木鱼水心','凉风','罗翔'};
figure;
bar(score);%条形图
set(gca, 'XTickLabel', projectNames); %每个条形图标签
xlabel('博主');
ylabel('加权总分');
title('得分');
grid on; % 网格线

@ -1,96 +0,0 @@
clc,clear,format short,close all;
load data_mh.mat;
[n,p]=size(x);
%标准化
X=zscore(x);
%协方差矩阵/相关系数矩阵
R=cov(X);
[V,D]=eig(R);%[特征向量,特征值]
lambda=diag(D);
lambda=lambda(end:-1:1);
total_contri=sum(lambda);
cum_contri=cumsum(lambda);
contri_rate=cum_contri/total_contri;
V1=rot90(V)';
disp(V1);
c1=V1(:,1);
c2=V1(:,2);
XX=X*c1;
YY=X*c2;
figure;
scatter(XX, YY, 'filled');
xlabel('第一主成分');
ylabel('第二主成分');
title('主成分得分图');
grid on;
%散点
figure;
scatter(XX,YY,'k.');
figure;
plot(c1, c2, 'o', 'MarkerSize', 8, 'MarkerFaceColor', 'b');
text(c1, c2, cellstr(num2str((1:p)')), 'VerticalAlignment','bottom', 'HorizontalAlignment','right');
xlabel('第一主成分');
ylabel('第二主成分');
title('主成分载荷图');
grid on;
%主成分得分图Score Plot
X = randn(100, 5);
% 主成分分析
[coeff, score, latent, tsquared, explained, mu] = pca(X);
% 绘制前两个主成分的得分图
figure;
scatter(score(:,1), score(:,2));
xlabel('第一主成分');
ylabel('第二主成分');
title('主成分得分图');
grid on;
% 添加数据点标签
text(score(:,1), score(:,2), num2str((1:size(score,1))'), 'FontSize', 8);

@ -1,46 +0,0 @@
clc,clear,close all;
%相关系数矩阵
r=[ 1.000,0.577,0.509,0.387,0.462
0.577,1.000,1.599,0.389,0.322
0.509,0.599,1.000,0.436,0.426
0.387,0.389,0.436,1.000,0.523
0.462,0.322,0.426,0.523,1.000];
[vec1,val,rate]=pcacov(r);%特征向量、特征值、贡献率
f1=repmat(sign(sum(vec1)),size(vec1,1),1);%调整符号
vec2=vec1.*f1;%是用 .*
f2=repmat(sqrt(val)',size(vec2,1),1);
a=vec2.*f2;%载荷矩阵
a1=a(:,1);
tcha1=diag(r-a1*a1');
a2=a(:,[1,2]);
tcha2=diag(r-a2*a2');
ccha2=r-a2*a2'-diag(tcha2);
con=cumsum(rate);
clc,clear,close all;
load data_mh.mat;
[n,p]=size(x);
%标准化
X=zscore(x);
%相关系数矩阵
r=cov(X);
[vec1,val,rate]=pcacov(r);%特征向量、特征值、贡献率
f1=repmat(sign(sum(vec1)),size(vec1,1),1);%调整符号
vec2=vec1.*f1;%是用 .*
f2=repmat(sqrt(val)',size(vec2,1),1);
a=vec2.*f2;%载荷矩阵
a1=a(:,1);
tcha1=diag(r-a1*a1');
a2=a(:,[1,2]);
tcha2=diag(r-a2*a2');
ccha2=r-a2*a2'-diag(tcha2);
con=cumsum(rate);

@ -1,11 +1,8 @@
import pandas as pd
<<<<<<< HEAD
import numpy as np
from scipy.stats import zscore
from sklearn.decomposition import PCA
=======
from scipy.stats import zscore
>>>>>>> remotes/origin/盘荣博
import matplotlib.pyplot as plt
from matplotlib.pyplot import ylabel
df = pd.read_excel("棉花产量论文作业的数据.xlsx")
@ -44,7 +41,7 @@ plt.scatter(data2[:,:1],data2[:,1:2],c='g')
plt.xlabel('压缩到0~1')
print(data==data1)
<<<<<<< HEAD
# plt.savefig("shuju.jpg",dpi=2000)
# plt.show()
md= PCA().fit(data)
@ -64,7 +61,7 @@ print('特征向量:')
print(d.T)
print(md.components_)
print(md.components_-d.T<=0.1)
=======
plt.savefig("shuju.jpg",dpi=2000)
plt.show()
>>>>>>> remotes/origin/盘荣博

Loading…
Cancel
Save