Arithmetic Progressions
题目大意:
求出满足条件A的等差数列;
A:长度为N(N<=25),每个元素都能表示成 两个数p,q的平方和(0<=p,q<=m<=250);
解题过程:
1.处理出所有的能拆成两个数平方和的数,放到一个表里,枚举数列的前2个元素,果断爆搜,果断超时。
2.看了下题解,发现可以加一个剪枝,如果 首项a+(n-1)*p >max(max=2*m*m),那么直接退出;不必一一在表中找到数列中的元素,只要开一个hash,表示某个数是否在表中,然后每次根据首项每次加公差p,然后看hash是否为true。然后就AC了。
还是非常不错的一道题目。。
Arithmetic Progressions的更多相关文章
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- Dirichlet's Theorem on Arithmetic Progressions 分类: POJ 2015-06-12 21:07 7人阅读 评论(0) 收藏
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- 洛谷P1214 [USACO1.4]等差数列 Arithmetic Progressions
P1214 [USACO1.4]等差数列 Arithmetic Progressions• o 156通过o 463提交• 题目提供者该用户不存在• 标签USACO• 难度普及+/提高 提交 讨论 题 ...
- POJ 3006 Dirichlet's Theorem on Arithmetic Progressions (素数)
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- poj 3006 Dirichlet's Theorem on Arithmetic Progressions【素数问题】
题目地址:http://poj.org/problem?id=3006 刷了好多水题,来找回状态...... Dirichlet's Theorem on Arithmetic Progression ...
- (素数求解)I - Dirichlet's Theorem on Arithmetic Progressions(1.5.5)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit cid=1006#sta ...
- USACO 1.4 Arithmetic Progressions
Arithmetic Progressions An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb ...
- Educational Codeforces Round 16 D. Two Arithmetic Progressions (不互质中国剩余定理)
Two Arithmetic Progressions 题目链接: http://codeforces.com/contest/710/problem/D Description You are gi ...
- 等差数列Arithmetic Progressions题解(USACO1.4)
Arithmetic Progressions USACO1.4 An arithmetic progression is a sequence of the form a, a+b, a+2b, . ...
- E - Two Arithmetic Progressions(CodeForces - 710D)(拓展中国剩余定理)
You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such ...
随机推荐
- 学习笔记day5:inline inline-block block区别
1. block元素可以包含block元素和inline元素:但inline元素只能包含inline元素.要注意的是这个是个大概的说法,每个特定的元素能包含的元素也是特定的,所以具体到个别元素上,这条 ...
- surfaceview介绍
[1]surfaceview 控件是一个重量级控件 [2]内部维护了2个线程 A 获取数据 负责显示 B 负责显示 获取数据 [3]他可以直接在子线程更新ui ...
- mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database
新安装的mysql密码是空的. ./mysql -u root -p use mysql SELECT `Host`,`User` FROM user; UPDATE user SET `Host` ...
- 转:C++中Static作用和使用方法
转自:http://blog.csdn.net/artechtor/article/details/2312766 1.什么是static? static 是C++中很常用的修饰符,它被用 ...
- iOS开发 判断代理以及代理方法是否有人遵循
if (self.delegate && [self.delegate respondsToSelector:@selector]) { return YES; }
- 串行通讯之.NET SerialPort
第1章串行通讯之.NET SerialPort 2 1 枚举串口 2 2 打开/关闭串口 2 3 写数据 3 3.1 写二进制数据 3 3.2 写文本数据 4 4 ...
- 日期操作类--SimpleDateFormat类
使用SimpleDateFormat格式化日期 SimpleDateFormat是一个以语言环境敏感的方式来格式化和分析日期的类.SimpleDateFormat允许你选择任何用户自定义日期时间格式来 ...
- Mongoose学习参考文档
一.快速通道 1.1 名词解释 Schema : 一种以文件形式存储的数据库模型骨架,不具备数据库的操作能力 Model : 由Schema发布生成的模型,具有抽象属性和行为的数据库操作对 Entit ...
- spring来了-04-AOP
概述 aspect object programming 面向切面编程 功能:可以实现“业务代码”与“关注点代码”分离 关注点代码:就是指重复执行的代码 业务代码:核心的业务功能 运行期间,执行核心业 ...
- [saiku] 源码整合[maven整合]
saiku源码的整合分为[普通web项目整合]和[maven整合]两种 本节主要是讲解如何整合为maven项目 转载自:http://blog.csdn.net/gsying1474/article/ ...