构造 HDOJ 5400 Arithmetic Sequence
题意:问有多少个区间,其中存在j使得ai + d1 == ai+1(i<j) && ai + d2 == ai+1 (i>j)
构造:用c1[i], c2[i]记录i为标杆左边最多几个符合以及右边最多几个符合,那么i的贡献为(c1[i]+1) * (c2[i] + 1);当d1==d2时,找出符合的连续区间,长度记为cnt,那么贡献为(cnt+1) * cnt / 2。
;
) ; ; ;
; ;
;
;
; ) ; ;
) ;
; ) );
;
}
构造 HDOJ 5400 Arithmetic Sequence的更多相关文章
- hdoj 5400 Arithmetic Sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5400 水题 #include<stdio.h> typedef long long LL; ...
- hdu 5400 Arithmetic Sequence
http://acm.hdu.edu.cn/showproblem.php?pid=5400 Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Ot ...
- hdu 5400 Arithmetic Sequence(模拟)
Problem Description A sequence b1,b2,⋯,bn are called (d1,d2)-arithmetic sequence ≤i≤n) such that ≤j& ...
- 水题 等差数列HDU 5400 Arithmetic Sequence
主要是要知道它对于等差数列的定义,单个数也可以作为等差数列且一定满足题意,另外就是要算清楚区间与区间的关系,考虑两大类情况,一种是d1区间和d2区间连在一起,另外一种情况就是其余情况. #includ ...
- (模拟)Arithmetic Sequence -- HDU -- 5400
链接: http://acm.hdu.edu.cn/showproblem.php?pid=5400 Time Limit: 4000/2000 MS (Java/Others) Memory ...
- Arithmetic Sequence(dp)
Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 51 Solved: 19[Submit][Status][We ...
- [Swift]LeetCode1027. 最长等差数列 | Longest Arithmetic Sequence
Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall t ...
- HZAU 21——Arithmetic Sequence——————【暴力 or dp】
Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1810 Solved: 311[Submit][Status] ...
- 华中农业大学第四届程序设计大赛网络同步赛-1020: Arithmetic Sequence,题挺好的,考思路;
1020: Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MB Submit: ->打开链接<- Descriptio ...
随机推荐
- curl -s 不输出统计信息
curl -s 不输出统计信息 学习了:https://blog.csdn.net/qinyushuang/article/details/44114583
- Dom对象的经常用法
Dom对象的经常用法: (1)getElementById() 查询给定ID属性值的元素,返回该元素的元素节点 1. 查询给定ID属性值的元素,返回该元素的元素节点.也称为元素对象. ...
- 微信小程序实战之 goods(订餐页)
项目目录: 模拟数据: utils / data.js function getSData() { var data = [ { "name": "热销榜", ...
- 2016/05/23 thinkphp M方法和D方法的区别
M方法和D方法的区别 ThinkPHP 中M方法和D方法都用于实例化一个模型类,M方法 用于高效实例化一个基础模型类,而 D方法 用于实例化一个用户定义模型类. 使用M方法 如果是如下情况,请考虑使用 ...
- ajax跨域问题解决(spring boot)
之前用的服务器响应头部添加Access-Control-Allow-Origin: *来解决的 public static void setResp(HttpServletResponse resp) ...
- log4j_自定义样式参数意义
#自定义样式 %c 输出所属的类目,通常就是所在类的全名 %C 输出Logger所在类的名称,通常就是所在类的全名 %d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比 ...
- 高负载linux调优
调整Linux内核参数: # vi /etc/sysctl.conf# tells the Kernel it's ok if services bind to non-existant IP ADD ...
- JavaScript 实现的 SHA1 散列
1.代码:/**** Secure Hash Algorithm (SHA1)* http://www.webtoolkit.info/***/ function SHA1 (msg) { ...
- android ndk环境搭建,如果是mac,请先装mac make编译器(可以使用Xcode进行安装)
Android SDK:android-sdk-mac_86Android NDK: android-ndk-r4b-darwin-x86EclipseADTCDTANT搭建Android SDK开发 ...
- 同步 Github fork 分支
/**************************************************************************** * 同步 Github fork 分支 * ...