The 12th Zhejiang Provincial Collegiate Programming Contest - D
2015-04-25 22:18
495 查看
#include<cstdio> #include<cstring> using namespace std; long long f[200005]; int vis[200005]; int main() { int t; int n; scanf("%d",&t); while(t--) { scanf("%d",&n); f[0]=0; memset(vis,0,sizeof(vis)); for(int i=1;i<=n;i++) { int x; scanf("%d",&x); f[i]=x+f[i-1]+(i-1-vis[x])*x; vis[x]=i; } long long ans=0; for(int i=1;i<=n;i++) ans+=f[i]; printf("%lld\n",ans); } return 0; }
相关文章推荐
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(2015浙江省赛)
- ZOJ 3875 Lunch Time (The 12th Zhejiang Provincial Collegiate Programming Contest )
- Ace of Aces【The 12th Zhejiang Provincial Collegiate Programming Contest】
- The 12th Zhejiang Provincial Collegiate Programming Contest
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
- The 12th Zhejiang Provincial Collegiate Programming Contest - A
- ZOJ 3869 Ace of Aces (The 12th Zhejiang Provincial Collegiate Programming Contest)
- The 12th Zhejiang Provincial Collegiate Programming Contest - G
- ZOJ 3870 Team Formation (The 12th Zhejiang Provincial Collegiate Programming Contest 数位DP+二分)
- The 12th Zhejiang Provincial Collegiate Programming Contest - H
- Lunch Time【The 12th Zhejiang Provincial Collegiate Programming Contest】
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
- ZOJ 3878 The 12th Zhejiang Provincial Collegiate Programming Contest - J
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
- The 12th Zhejiang Provincial Collegiate Programming Contest(部分)
- The 12th Zhejiang Provincial Collegiate Programming Contest->B-Team Formation
- The 12th Zhejiang Provincial Collegiate Programming Contest - J
- ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )
- The 12th Zhejiang Provincial Collegiate Programming Contest - L
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)