hdoj 5400 Arithmetic Sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5400
水题
#include<stdio.h>
typedef long long LL;
const int MAXN = 1e5;
LL cnt( int x ){
)/;
}
int main(){
int n;
int d1, d2;
int flag;
int ct;
long long ans;
int a[MAXN];
while(~scanf("%d %d %d",&n,&d1,&d2)){
; i < n; ++i){
scanf("%d",&a[i]);
}
flag = ;
ans = n;
ct = ;
; i < n; ++i){
])== d1 ){
){
flag = ;
ans += cnt(ct);
ct = ;
}
else
ct++;
}
])==d2){
flag = ;
ct++;
}
else{
ans += cnt(ct);
ct = ;
}
}
if(ct)
ans += cnt(ct);
printf("%I64d\n",ans);
}
}
hdoj 5400 Arithmetic Sequence的更多相关文章
- 构造 HDOJ 5400 Arithmetic Sequence
题目传送门 题意:问有多少个区间,其中存在j使得ai + d1 == ai+1(i<j) && ai + d2 == ai+1 (i>j) 构造:用c1[i], c2[i] ...
- 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 ...
随机推荐
- PHP学习笔记01——基础语法
<!DOCTYPE html> <html> <?php // 1.使用$加变量名来表示变量,php是弱类型语言,不要求在使用变量前声明,第一次赋值时变量才被创建 $a ...
- (转)hadoop基本操作命令
http://www.cnblogs.com/gpcuster/archive/2010/06/04/1751538.html 在这篇文章中,我们默认认为Hadoop环境已经由运维人员配置好直接可以使 ...
- ecshop显示所有分类树栏目
1.找到 category.php 和goods.php 两个文件修改: $smarty->assign('categories', get_categories_tree(0)); // 分类 ...
- 在ACCESS中创建数据库和查询(ACCESS 2000)
备份还原数据库 备份.还原 —— 复制\粘贴 压缩修复数据库命令 —— 复制该文件并重新组织,并重新组织文件在磁盘上的储存方式.压缩同时优化了Access数据库的性能.(工具——实用数据库工具或者工具 ...
- 【转】Github轻松上手2-如何使用命令行创建和管理repo
转自:http://blog.sina.com.cn/s/blog_4b55f6860100zzhd.html 如果你对这种怀旧的方式很感冒,不妨参考这里: http://help.github.co ...
- C/C++中static关键字详解-zz
静态变量作用范围在一个文件内,程序开始时分配空间,结束时释放空间,默认初始化为0,使用时可以改变其值. 静态变量或静态函数只有本文件内的代码才能访问它,它的名字在其它文件中不可见.用法1:函数内部声明 ...
- Drupal 7.23:函数module_invoke_all()注释
/** * Invokes a hook in all enabled modules that implement it. * * All arguments are passed by value ...
- LoadRunner界面分析(二)
1.Controller 2.创建运行场景 3.方案设计 4.Resuls settting 5.监视方案
- php codeigniter (CI) oracle 数据库配置-宋正河整理
database.php 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 $active_group = 'default'; $active_record ...
- spring开发相关网址
jar包下载地址:http://repo.springsource.org/libs-release-local/org/springframework/spring/