其他分享
首页 > 其他分享> > 5.2个人赛

5.2个人赛

作者:互联网

B 随机序列

题意:算方差和极差,超简单

ac代码:

#include<iostream> #include<cstdio> #include<algorithm> using namespace std; #define ll long long #define N 10004 int main() {    int t;     cin>>t;     while(t--){     ll max1=-111,min1=60000;         int n;         cin>>n;         ll a[N];         double sum=0,sum1=0;         for(int i=0;i<n;i++){             cin>>a[i];             sum+=a[i];             max1=max(max1,a[i]);             min1=min(min1,a[i]);         }         sum=sum*1.0/n;        for(int i=0;i<n;i++){         sum1+=(a[i]-sum)*(a[i]-sum);        }        cout<<max1-min1<<" ";        printf("%.3lf\n",sum1/n);     } }
D

卡拉兹函数

本题最简单,相信都会

#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a%2==0)
cout<<a/2<<endl;
else cout<<3*a+1<<endl;
}

标签:5.2,cout,int,sum,cin,sum1,个人赛,min1
来源: https://www.cnblogs.com/1324a/p/12849867.html