ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )
对于没有题目积累和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 )的更多相关文章
- 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 ...
- 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 ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 深入理解DLL文件
1.LIB与DLL文件的区别 DLL是一个完整的程序,称为“动态链接库”,DLL中包含的主要有三块内容:1.全部变量 2.函数接口 3.资源:DLL中有一个函数导出表,其中每一项都是一个函数名称.通过 ...
- PostQuitMessage, PostThreadMessage( WM_QUIT )
http://blogs.msdn.com/b/oldnewthing/archive/2005/11/04/489028.aspx Why is there a special PostQuitMe ...
- 根据PID和VID得到USB转串口的串口号
/******************************************************************************* * * FindAppUART.cpp ...
- WinForm特效:拦截窗体上各个部位的点击
windows窗体的标题栏无法直接通过一些默认的事件来控制,需要了解和WM_NCHITTEST相关的windows消息. 以下示例演示了最简单的效果片断: 他会把客户区和标题栏的效果互换,比如无法按住 ...
- cocos2dx的图片载入
//data: 图片文件数据 dataLen: 文件长度 bool Image::initWithImageData(const unsigned char * data, ssize_t dataL ...
- 【转】SoapUI5.0创建WebService接口模拟服务端
原文:http://blog.csdn.net/a19881029/article/details/26348627 使用SoapUI创建WebService接口模拟服务端需要接口描述文件 MathU ...
- 微信公共服务平台开发(.Net 的实现)8-------处理图片(上传下载发送)
举个例子,有人对着我们的公共微信号拍个照片发送过来,然后我们处理这个照片,比如进行ocr识别字(随后就会降到这个例子),或者人脸识别,或者拍照取证等,这些功能都是相当有用的.那么我们现在就要分析一下这 ...
- 【Java基础】Java面试题目整理与解说(二)
1.Collection 和 Collections 的差别. Collection 是集合类的上级接口,继承于他的接口主要有 Set 和 List. Collections 是针对集合类的一个帮助类 ...
- spark1.2.0编译
spark 有三种编译方式:SBT.MAVEN.make-distribution.sh.SBT.MAVEN两种方式打出来的包比较大,不适合部署使用.因此我们通常使用第三种方式打包. ./make-d ...
- Windows 之 CMD命令
1. ipconfig 查看 Windows IP 配置 2. ping IP地址 查看远程IP是否通畅 2. ipconfig/flushdns 刷新和重置缓存 3. netsh winsock r ...