题目传送门

题意:问有多少个区间,其中存在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的更多相关文章

  1. hdoj 5400 Arithmetic Sequence

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5400 水题 #include<stdio.h> typedef long long LL; ...

  2. hdu 5400 Arithmetic Sequence

    http://acm.hdu.edu.cn/showproblem.php?pid=5400 Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Ot ...

  3. hdu 5400 Arithmetic Sequence(模拟)

    Problem Description A sequence b1,b2,⋯,bn are called (d1,d2)-arithmetic sequence ≤i≤n) such that ≤j& ...

  4. 水题 等差数列HDU 5400 Arithmetic Sequence

    主要是要知道它对于等差数列的定义,单个数也可以作为等差数列且一定满足题意,另外就是要算清楚区间与区间的关系,考虑两大类情况,一种是d1区间和d2区间连在一起,另外一种情况就是其余情况. #includ ...

  5. (模拟)Arithmetic Sequence -- HDU -- 5400

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=5400 Time Limit: 4000/2000 MS (Java/Others)    Memory ...

  6. Arithmetic Sequence(dp)

    Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 51  Solved: 19[Submit][Status][We ...

  7. [Swift]LeetCode1027. 最长等差数列 | Longest Arithmetic Sequence

    Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall t ...

  8. HZAU 21——Arithmetic Sequence——————【暴力 or dp】

    Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1810  Solved: 311[Submit][Status] ...

  9. 华中农业大学第四届程序设计大赛网络同步赛-1020: Arithmetic Sequence,题挺好的,考思路;

    1020: Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MB Submit:  ->打开链接<- Descriptio ...

随机推荐

  1. jsoncpp的api简要说明

    1  jsoncpp的api简要说明 1,解析(json字符串转为对象) std::string strDataJson; Json::Reader JReader; Json::Value JObj ...

  2. PHP 按位与或 (^ 、&)

    今天朋友群里朋友问了下 按位与或的问题.. 按位于主要是对二进制数操作. <?php $a = 1; $b = 2; $c = $a^b; ?> 这里不是单纯的相加关系 十进制 1换算成二 ...

  3. 我的家乡:三河古镇已经登上央视CCTV-1新闻联播啦!

    在烟雨朦胧时走在古镇的青石街上,别有一番风味!第一幅图为央视的直播车,第二副图为漂亮的三河夜景色!

  4. js调试记录,将客户的调试信息保存到服务器端的一个小方法。

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. UITableViewController的子控件不随着滑动

    UITableViewController的子控件不随着滑动 我们知道有时候使用UITableViewController简单便捷,省事,但是如果我们使用了addSubview,无论是[self.vi ...

  6. MVC+ZTree实现对树的CURD及拖拽操作

    上一讲中,我们学习了如何使用zTree对一棵大树(大数据量的树型结构的数据表,呵呵,名称有点绕,但说的是事实)进行异步加载,今天这讲,我们来说说,如何去操作这棵大树,无非就是添加子节点,删除节点,编辑 ...

  7. Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

    Content-Type https://tools.ietf.org/html/rfc7231#section-3.1.1.5 https://tools.ietf.org/html/rfc7231 ...

  8. 有关MAC、PHY和MII

    这是一篇转载,原文链接:http://www.cppblog.com/totti1006/archive/2008/04/22/47829.html 以太网(Ethernet)是一种计算机局域网组网技 ...

  9. 超线程技术——超线程技术让(P4)处理器增加5%的裸晶面积,就可以换来15%~30%的效能提升,本质单核模拟双核!和异步编程的思想无异。

    超线程是Intel 所研发的一种技术,于2002年发布.超线程的英文是HT技术,全名为Hyper-Threading,中文又名超线程.超线程技术原先只应用于Intel Xeon处理器中,当时称为Sup ...

  10. CAShapeLayer和贝塞尔曲线配合使用

    前言 CAShapeLayer继承自CALayer,因此,可使用CALayer的所有属性.但是,CAShapeLayer需要和贝塞尔曲线配合使用才有意义. 关于UIBezierPath,请阅读文章:i ...