1 条题解
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int main(){ int a[1500]={0},b[1500]={0},i,n; double x=0,y=0; double x1=0,x2=0; cin>>n; for(i=0;i<n;i++)cin>>a[i]; for(i=0;i<n;i++)cin>>b[i]; for(i=0;i<n;i++){ x1+=a[i]; x2+=b[i]; } x2/=n; x1/=n; for(i=0;i<n;i++){ x+=(a[i]-x1)*(a[i]-x1); y+=(b[i]-x2)*(b[i]-x2); } if(abs(x)<abs(y))cout<<"jia"<<endl; else cout<<"yi"<<endl; return 0; }
Python :
n = int(input()) a = input().split() b = input().split() av1 = 0 av2 = 0 su1 = 0 su2 = 0 s1 = 0 s2 = 0 l1 = [] l2 = [] for v in a: l1.append(int(v)) for v in b: l2.append(int(v)) for i in range(0, n): su1 += l1[i] av1 = su1 / n for i in range(0, n): su2 += l2[i] av2 = su2 / n for i in range(0, n): s1 += (l1[i] - av1) * (l1[i] - av1) for i in range(0, n): s2 += (l2[i] - av2) * (l2[i] - av2) if s1 < s2: print('jia') if s1 > s2: print('yi')
- 1
信息
- ID
- 2277
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者