2,3wa了求救
查看原帖
2,3wa了求救
1533267
rrsmg楼主2024/11/21 21:27
#include<iostream>
using namespace std;
#define ll unsigned long long
ll jiecheng(ll a)
{
	ll ans=1;
	for(ll i=1;i<=a;i++)
	     {
		 	ans=ans*i;
		 }
	return ans;
}
ll c(ll a,ll b)
{
	ll ans;
	ans=jiecheng(b)/(jiecheng(a)*jiecheng(b-a));
	return ans;
}
int main()
{
	ll a[2000];
	ll i=0;
	while(cin>>a[i])
	    {
			i++;
			if(getchar()=='\n')
			    {
					break;
				}
		}
	ll num=i;
	//cout<<i;
	//数字统计正确
       //cout<<ncifang(1)<<" "<<ncifang(2)<<" "<<ncifang(3)<<" ";
    //cout<<jiecheng(2)<<" "<<jiecheng(4)<<" "<<jiecheng(5);
    //阶乘表示正确 
    //cout<<c(2,3)<<"  "<<c(3,6);  
	//组合数表示正确
    ll sum=0;
	for(i=1;i<=num;i++)
	      {
		  	sum=sum+i*c(i,num);                //元素总个数 
		  }
	//cout<<"元素总个数等于"<<sum<<endl;; 
	sum=sum/num;                           //单个元素出现个数
	ll ans=0;                          
	for(ll i=0;i<=num-1;i++)
	        {
				ans=ans+a[i];
			}
//	cout<<"原集合元素之和"<<ans<<endl;
	 cout<<ans*sum;
	return 0;
}
2024/11/21 21:27
加载中...