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 ...
随机推荐
- Android 将文件保存到SD卡,从卡中取文件,及删除文件
//保存到SD卡 private static String sdState = Environment.getExternalStorageState(); private static S ...
- Codeforces Beta Round #5 E. Bindian Signalizing 并查集
E. Bindian Signalizing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- TP复习11
## ThinkPHP 3.1.2 模板中的基本语法#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲:一.导入CSS和JS文件 1.css link js ...
- Preventing CSRF in Java web apps---reference
reference from:http://ricardozuasti.com/2012/preventing-csrf-in-java-web-apps/ Cross-site request fo ...
- 512字节纠错1位的ECC校验码生成演示
Flash型号: NandFlash型号:TC58NVG2S3ETA00 pagesize: 2KB oobsize : 64B blocksize : 128K 关于ECC可以参考:http:// ...
- Java获取当前进程的所有线程
public class MainClass { public static void main(String[] args) { ThreadGroup group = Thread.current ...
- 浅析SQL Server 2005中的主动式通知机制
一.引言 在开发多人同时访问的Web应用程序(其实不只这类程序)时,开发人员往往会在缓存策略的设计上狠下功夫.这是因为,如果将这种环境下不常变更的数据临时存放在应用程序服务器或是用户机器上的话,可以避 ...
- Web Service 之 开发、部署
一.C#开发WebService 在 VS2010 中新建 ASP.NET Web 应用程序,取名 WebTest. 应用程序下新建项其实最简单的就是建一个网站项目,直接" 添加新项→Web ...
- 沈逸老师PHP魔鬼特训笔记(9)--进化
回到第一课,我们学过PHP母体,了解过解析PHP程序.PHP其实内置了一个web服务器,专门给我们开发测试使用,那么接下来我们要完成的是:生成后创建一个web 服务,在浏览器中可以访问. PHP的母体 ...
- ARC 和 MRC 小结
ARC 和 MRC 内存管理 从 MRC—>ARC 就是将内存管理部分,从开发者的函数中转移到函数外部的runtime 中.由于 runtime 的开发简单,逻辑层次高,所以 runtime 的 ...