对于没有题目积累和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. 使用VS连接SQLServe时提示未能载入文件或程序集“System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKey

    解决方法:         就是去微软主页下载两个Microsoft SQL Server 2012补丁包,SQLSysClrTypes.msi和SharedManagementObjects.msi ...

  2. java android ExecutorService 线程池解析

    ExecutorService: 它也是一个接口,它扩展自Executor接口,Executor接口更像一个抽象的命令模式,仅有一个方法:execute(runnable);Executor接口简单, ...

  3. 微软停服 XP系统到底伤害了谁?

    http://majihua.baijia.baidu.com/article/10386 微软现在成了招人恨的角色,因为其史上最成功的操作系统WINDOWS XP在4月8日就将停止服务,而社会上对X ...

  4. UVALive 4192 Close Enough Computations 水题

    Close Enough Computations 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge& ...

  5. 用python写makefile

    温馨提示:阅读本文的同学最好能了解makefile和python的编写规则. 不懂的同学能够先保存在收藏夹.以便日后查看. 事实上之前我一直非常懒,我不想了解makefile规则.由于在linux下开 ...

  6. 我的CMS心路历程,DNN And Umbraco

    在比较了众多CMS系统后,还是把焦点定在DNN和Umbraco两个系统上,这两个系统都可以使用UserControl扩展自己需要的功能. DNN的架构比较复杂,Module.Skin.Containe ...

  7. CentOS 7 ibus 导入第三方词库

    CentOS 7 自带的输入法是ibus默认有带拼音输入法“Intelligent Pinyin 1.6.91“,但是在使用过程中发现很多词汇没有.所以就想捣鼓一下,怎么把像搜狗或者其他输入法的数据库 ...

  8. JSON特殊字符处理

    JSON 是适用于 Ajax 应用程序的一种有效格式,原因是它使 JavaScript 对象和字符串值之间得以快速转换.由于 Ajax 应用程序非常适合将纯文本发送给服务器端程序并对应地接收纯文本,相 ...

  9. 【手把手教你Elmah】如何在MVC.NET项目中在线查看【错误日志】

     一.  在NuGet下载Elmah.MVC dll文件!  或者点击下载dll文件,并且引用客户端. 二.配置WebConfig <sectionGroup name="elmah& ...

  10. Cyclic Nacklace

    Problem Description CC always becomes very depressed at the end of this month, he has checked his cr ...