ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )
来源:互联网 发布:实用办公软件基础教程 编辑:程序博客网 时间:2024/05/14 02:01
对于没有题目积累和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; }
0 0
- ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )
- ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )
- ZOJ 3869 Ace of Aces (The 12th Zhejiang Provincial Collegiate Programming Contest)
- ZOJ 3870 Team Formation (The 12th Zhejiang Provincial Collegiate Programming Contest 数位DP+二分)
- ZOJ 3875 Lunch Time (The 12th Zhejiang Provincial Collegiate Programming Contest )
- The 12th Zhejiang Provincial Collegiate Programming Contest
- The 12th Zhejiang Provincial Collegiate Programming Contest - A
- The 12th Zhejiang Provincial Collegiate Programming Contest - G
- The 12th Zhejiang Provincial Collegiate Programming Contest - H
- The 12th Zhejiang Provincial Collegiate Programming Contest - J
- The 12th Zhejiang Provincial Collegiate Programming Contest - L
- Lunch Time【The 12th Zhejiang Provincial Collegiate Programming Contest】
- The 12th Zhejiang Provincial Collegiate Programming Contest - D
- The 12th Zhejiang Provincial Collegiate Programming Contest(部分)
- The 12th Zhejiang Provincial Collegiate Programming Contest
- The 13th Zhejiang Provincial Collegiate Programming Contest (杂谈)
- The 14th Zhejiang Provincial Collegiate Programming Contest (待续)
- ZOJ 3876 May Day Holiday (The 12th Zhejiang Provincial Collegiate Programming Contest)
- jsp中c标签长度的判断和截取
- UVa 10954 Add All
- windows 命令收集--持续更新
- crash 捕获
- android中的 ellipsize
- ZOJ 3872 Beauty of Array (The 12th Zhejiang Provincial Collegiate Programming Contest )
- Time类中的运算符重载
- MySQL不支持InnoDB存储引擎解决方法
- Mobile Terminal无法使用常用Unix命令
- [MySQL登录错误] ERROR1045 (28000): Access denied for user 'omonroy'@'20.112.251.19' (using password:YES)
- UCSD非易失性存储工作室——耐久性主存的铺路人
- Linux招聘技术面试题
- Error inflating class错误
- Git Notes