跳到正文

个人记录

反思

Cmz0720约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年2月22日
篇幅
约 2 分钟

版本

  1. v1当前

t1t2t3AC; t4 #include<bits/stdc++.h> using namespace std; long long a[10005],b[10005]; int main(){ long long n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i];

C++
}
for(int i=1;i<=n-1;i++){
	b[i]=abs(a[i]-a[i+1]);
}
sort(b+1,b+1+n-1);
for(int i=1;i<=n-1;i++){
	if(b[i]!=i){
		cout<<"Not jolly";
		return 0;

	}
}
cout<<"Jolly";

}

复制Jolly复制错了,未进行排序,代码不熟练,要练。 t5 #include<bits/stdc++.h> using namespace std; long long n,h; double t; struct st{ int xh,hl; }a[1230]; int cmp(st s1,st s2){ return s1.hl<s2.hl; } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].hl; a[i].xh=i; } sort(a+1,a+1+n,cmp); for(int i=1;i<=n;i++){ h+=a[i].hl*(n-i); } for(int i=1;i<=n;i++){ cout<<a[i].xh<<” ”; } cout<<endl; t=h*1.0/n; printf(“%.2f”,t); } 结构体,数组排序不熟练,未用浮点型。

原文