C. Sequence Pair Weight——Codeforces Round #721 (Div. 2)

https://codeforces.com/contest/1527/problem/C
A sequence b is a subsegment of a sequence a if b can be obtained from a by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
——题意看清!!several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
弄成子列了,不要这样。还用py做了大数。。
比赛时,不要慌,思路仍然要想透想深一点

#include<bits/stdc++.h>
#ifdef LOCAL
FILE*FP=freopen("text.in","r",stdin);
#endif
using namespace std;
#define int unsigned long long 
//题意看清! 
map<int,int>m;
signed main(){
	int t;
	scanf("%llu",&t);//long long输入 
	while(t--){
		int n;
		scanf("%llu",&n);
		m.clear();
		int te,sum=0;
		for(int i=0;i<n;i++){
			scanf("%llu",&te);
			sum+=m[te]*(n-i);
			m[te]+=(i+1);
		}
		printf("%llu\n",sum);
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值