题目大意:

求出满足条件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的更多相关文章

  1. [Educational Codeforces Round 16]D. Two Arithmetic Progressions

    [Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...

  2. 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 ...

  3. 洛谷P1214 [USACO1.4]等差数列 Arithmetic Progressions

    P1214 [USACO1.4]等差数列 Arithmetic Progressions• o 156通过o 463提交• 题目提供者该用户不存在• 标签USACO• 难度普及+/提高 提交 讨论 题 ...

  4. POJ 3006 Dirichlet's Theorem on Arithmetic Progressions (素数)

    Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  5. poj 3006 Dirichlet's Theorem on Arithmetic Progressions【素数问题】

    题目地址:http://poj.org/problem?id=3006 刷了好多水题,来找回状态...... Dirichlet's Theorem on Arithmetic Progression ...

  6. (素数求解)I - Dirichlet&#39;s Theorem on Arithmetic Progressions(1.5.5)

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit cid=1006#sta ...

  7. USACO 1.4 Arithmetic Progressions

    Arithmetic Progressions An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb ...

  8. Educational Codeforces Round 16 D. Two Arithmetic Progressions (不互质中国剩余定理)

    Two Arithmetic Progressions 题目链接: http://codeforces.com/contest/710/problem/D Description You are gi ...

  9. 等差数列Arithmetic Progressions题解(USACO1.4)

    Arithmetic Progressions USACO1.4 An arithmetic progression is a sequence of the form a, a+b, a+2b, . ...

  10. E - Two Arithmetic Progressions(CodeForces - 710D)(拓展中国剩余定理)

    You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such ...

随机推荐

  1. SQL & PL/SQL 模块总结

    SQL 1. 各种function 2. merge 3. connect by PL/SQL 1. pl/sql 寄出 2. 游标 3. procedure 4. function 5. packa ...

  2. MyEclipse8.5启动无法选择工作空间的问题

    方法一:打开Window---Preferences---General---Startup and Shutdown,勾选Prompt for workspace on startup 选项,再次登 ...

  3. Three.js 3D特效学习

    一.Three.js基本介绍 Three.js是JavaScript编写的WebGL第三方库.提供了非常多的3D显示功能.Three.js 是一款运行在浏览器中的 3D 引擎,你可以用它创建各种三维场 ...

  4. 20160805_笔记本_CentOS6.4x64分区

    1.严gong 笔记本 CentOS6.4x64分区: 1.1.OS自动分区的方案: 1.2.我模仿上面的方案,自己弄的方案:(没有LVM卷组) 2.

  5. CLGeocoder Error Domain=kCLErrorDomain Code=2

    使用CLGeocoder解码地址时,遇到错误 Error Domain=kCLErrorDomain Code=2 代码: #pragma mark 跟踪定位代理方法,每次位置发生变化即会执行(只要定 ...

  6. Windows下DLL查找顺序

    目录 第1章说明    2 1.1 查找顺序    2 1.1.1 检查DllCharacteristics字段    3 1.1.2 读取manifset资源    3 1.1.3 读取manifs ...

  7. 创建和使用Windows静态链接库

    首先明确这篇文章的目的,我希望大家能够通过这篇文章了解一下如何在实际工作中创建和使用Windows平台下的静态链接库.关于链接库的概念,希望大家参考维基百科"Library"词条( ...

  8. 能源项目xml文件 -- app-context.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  9. Computer assembly and maintenance

    转载请注明出处: 我所遇见的世界会更美好 第一章 计算机的基本构成和组装 1,内存的组成? (1)  RAM(随机存取存储器) (2)  ROM(只读存储器) (3)  Cache(高速缓存) 2,S ...

  10. 5个开发人员不应该错过的最好跨平台PHP编辑器

    IDE(集成开发环境)或换句话说PHP编辑器是开发人员在构建移动或Web应用必不可少的工具.在这篇文章中,我们将讨论有关PHP编辑器并分享5个最好的跨平台的PHP编辑器. 1. NetBeans Ne ...