Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
c946a92701 | 1 year ago |
|
2b2079026a | 1 year ago |
|
321434f837 | 1 year ago |
|
8b36d3da1b | 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,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);
|
||||
|
||||
|
Loading…
Reference in new issue