当前位置:网站首页>7-6 sum of combinatorial numbers

7-6 sum of combinatorial numbers

2022-07-06 16:43:00 HBUcs2020

The problem is very simple , But found a different solution

/ Enter each number in turn , The number of times each number appears in tens and tens is n-1

#include<iostream>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        // Enter each number in turn , The number of times each number appears in tens and tens is n-1
        sum+=a[i]*11*(n-1);
    }
//    for(int i=0;i<n;i++)
//    {
//        for(int j=0;j<n;j++)
//        {
//            if(i!=j)
//                sum+=a[i]*10+a[j];
//        }
//    }
    cout<<sum<<endl;;
    return 0;
}

原网站

版权声明
本文为[HBUcs2020]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131314584101.html