Codeforces Round #721 (Div. 2) C. Sequence Pair Weight
Posted 尘封陌路
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #721 (Div. 2) C. Sequence Pair Weight相关的知识,希望对你有一定的参考价值。
如图:
AC代码:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
ll a[N];
map<ll,ll> mp;
int main()
int t;
cin>>t;
while(t--)
int n;
cin>>n;
mp.clear();
ll ans=0;
for(int i=1;i<=n;i++)
cin>>a[i];
ans+=mp[a[i]]*(n-i+1);
mp[a[i]]+=i;
cout<<ans<<"\\n";
return 0;
以上是关于Codeforces Round #721 (Div. 2) C. Sequence Pair Weight的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #721 (Div. 2) Codeforces-1527
Codeforces Round #721 (Div. 2)
C. Sequence Pair Weight——Codeforces Round #721 (Div. 2)
Codeforces Round #721 (Div. 2) C. Sequence Pair Weight(计算贡献/STL)