对于没有题目积累和clever mind的我来说,想解这道题还是非常困难的,也根本没有想到用dp。

from:

http://blog.csdn.net/u013050857/article/details/45285515

#include <bits/stdc++.h>
using namespace std;
#define LL unsigned long long
LL a[100010];
int main()
{
int n,m;
scanf("%d",&n);
while(n--){
scanf("%d",&m);
memset(a,0,sizeof(a));
LL sum=0,dp=0;
for(int i=1;i<=m;i++){
int x;
scanf("%d",&x);
dp=(i-a[x])*x+dp;
sum+=dp;
a[x]=i;
}
printf("%llu\n",sum);
}
return 0;
}

ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )的更多相关文章

  1. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  3. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  6. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504  The 12th Zhejiang Provincial ...

  8. zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...

  9. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)

    Floor Function Time Limit: 10 Seconds      Memory Limit: 65536 KB a, b, c and d are all positive int ...

随机推荐

  1. SAE/ISO standards for Automotive

    On-Board Diagnostics J1962 Diagnostic Connector Equivalent to ISO/DIS 15031-3: December 14, 2001J201 ...

  2. How do I place a group of functions or variables in a specific section?

    http://supp.iar.com/Support/?Note=27498 EWARM v5.xx (and newer) The placement of a few functions in ...

  3. ssh 命令行通过私钥登录其它设备

    ssh -i root(私钥文件) root@IP (被访问的服务器IP) 这里备份一下了

  4. hdu 4497 GCD and LCM 数学

    GCD and LCM Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4 ...

  5. cdoj 25 点球大战(penalty) 模拟题

    点球大战(penalty) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/2 ...

  6. DirectSound的应用

    假设仅仅使用PlaySound()这个API函数来表现声音效果的话,那么就无法表现出声音的混音效果,由于PlaySound在播放还有一个声音时,必定会导致现有声音的停止.因此,使用 PlaySound ...

  7. 微信公共服务平台开发(.Net 的实现)6-------自定义菜单

    用户自定义菜单制作时,需要用到access_token,我们直接使用前面讲解的IsExistAccess_Token()函数.我理解的微信公共平台里面菜单分为button和sub_button,即菜单 ...

  8. iOS 2D绘图详解(Quartz 2D)之Bitmap

    什么是Bitmap? Bitmap叫做位图,每一个像素点由1-32bit组成.每个像素点包括多个颜色组件和一个Alpha组件(例如:RGBA). iOS中指出如下格式的图片 JPEG, GIF, PN ...

  9. DQS安装失败——系统重新引导是否处于挂起状态

    问题:         安装完SQL Server 2012后,准备安装DQS服务,但是总是提示:操作"检查系统重新引导是否处于挂起状态"已完成,但有错误,正在中止安装.非常无奈, ...

  10. 第1章 游戏之乐——让CPU占用率曲线听你指挥

    让CPU占用率曲线听你指挥 写一个程序,让用于来决定Windows任务管理器(Task Manager)的CPU占用率.程序越精简越好,计算机语言不限.例如,可以实现下面三种情况: CPU的占用率固定 ...