POJ 1320 Street Numbers(佩尔方程)
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 3078 | Accepted: 1725 |
Description
Write a program to find pairs of numbers that satisfy this
condition. To start your list the first two pairs are: (house number,
last number):
6 8
35 49
Input
Output
Sample Input
Sample Output
6 8
35 49
题目意思也就是,从家里向右走走到街道尾部经过的编号之和(不包括自己家)和从家里向左走走到街头经过的编号之和(不包括自己家)相等
设自己家的编号为m,街道共有n家,所以有
aaarticlea/gif;base64,R0lGODlhcAEOALMAAP///wAAAO7u7kRERLq6utzc3HZ2dpiYmDIyMszMzGZmZlRUVIiIiKqqqiIiIhAQECH5BAEAAAAALAAAAABwAQ4AAAT+EAAxiLw4632YqlsoSke3HGOqrmw7UpYrzy5M3zjWfXHu/4CC4RDo+Q4CSSHQ+A0lggAKSK1ehESjdZvBFrlgUjLIDJtFX9VBq3EkLgtHap36XB6LOfscTvNddCt+I4FmhSFucHKEe1aHN4MijxoPUwAGAXotUZYhk39ckaCago0Zn46mEpUXmKSGqiyiHLEZca8qBgNqtTQdDAIlCwTBBwtvVbM4v8XDzciMsr2oF8zCxMLQnr2KuGDUEg0MwNcZyqfcE2XRKg0KC2PsVgIES1MNDlMHu8npKvT2wuUjwU9einM6VAGUIlBfwW2b1kny50thPYYAGiAwNy3dAAb+vFokeKCNFhcL+KotupSnn4h3C2LKlGlAA8qVB1YaaGlwBMJqqm6qbMUTIouPIc+AEyqBwUMAymDGRIBgZs0Q40JIXUDVaooFDzRs7UqzioKrABagHdDpQoIBcOPKBRni54yzcNa2lTC2atm6jfp6FYtW7QW2YmeSjYlWQ9YNgv/6iMwYcmG6F+wCAHdBHAvOx1oFKNCzyoMep6GMtqLZRepVMaKQ9oamo4rXAF7Lpr3B8wrOP4DjXo1BM3ACljAbDbGkiYQFmUoDWXIl+uaNFH2a2jqzsgbqSqwfwM57g/FY4MlUIz9RBfILyk0qRW89pZHzKRIoIMDfXflWYwjJ8EB8GnBWADxKIBiEggeOMV41BSkAEoE4tPbZRgRdICEAFCYkzW+xPJghXxNKh4F+/BHgn4lXMOhiPMt5giEAeIEkgC4BIGBASQXG8kAAQAJZlHwjMGAAAws4x6IEIyHTJJMkQYnMExJQCUACR8J4w40D5LgjFVZaiSUw/0GBo448opNCmJaMqaWaI/wYZABD9phflFfi+eSSl7SZZUVbACeDoKMUCgqhLSB6g6Ig8sFoDm/+EKkPkxpqaaGV4pApFZvS0KmkOUQAADsA" alt="" />
化简整理得
aaarticlea/gif;base64,R0lGODlhawASALMAAP///wAAAJiYmIiIiGZmZkRERLq6uu7u7tzc3KqqqiIiIszMzFRUVBAQEHZ2djIyMiH5BAEAAAAALAAAAABrABIAAAT+EMhJq61pOHK7/1S2gWRpfscgMc7pVunavnRNGY8k5PaJ67ye8ISQjIalIuCI/AgGhIJBqFA2S9WrR3CQIAIJG2OqJY3LHcViwlDUBmsr2gIHyC8Csq0hmDgCNAkJBwgqcxaChIZbekhtOgMDBwICY5OVa3YBmwEzSBmSlGeanJ4deSCgl6MwYAAHBl99AAkKswIFhxKwshIJQS6oHrwBs78XBYZTtRMCbkYMJwQM1NXWphLLzwADuTTCHdoT3XSLEgSeLBMFs7oA6GzmH9PVDw/XF/Ar8hkWDXr/dgW4MyeghIE1wHkwCADhBAPtDH2ZMBEIgEbzrGlUZ6EiLTdKGEsovOCRGZkFBAyoTMABwI5m3t6pkFfm5bkWNEmMtGDzHU4JDThtiraknYN2CxxIcnd0QtKlL3ZWaCrhaRd3WKOGzMq1zFUbEQAAOwA=" alt="" />
配凑得aaarticlea/gif;base64,R0lGODlhugASALMAAP///wAAAKqqqoiIiHZ2drq6ulRUVO7u7tzc3JiYmCIiIjIyMhAQEMzMzERERGZmZiH5BAEAAAAALAAAAAC6ABIAAAT+EMhJq61ikHe7/6CUbWFpnmiqrtYxSAbBzpQLy3Su73xXLJIEsJf6BYfEpHL5QUhIzJITAI1ar6KBRkBTTIkN3MkLFl8PjgIRrRa1AQPuyvAmKjgnevKORRASAXU0foBvBgcTCAYrAw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Aw34AIJthBBAA7AA==" alt="" />,所以转化为佩尔型方程aaarticlea/gif;base64,R0lGODlhYgAUALMAAP///wAAAKqqqpiYmHZ2drq6ulRUVNzc3BAQEMzMzDIyMu7u7mZmZoiIiCIiIkRERCH5BAEAAAAALAAAAABiABQAAAT+EMhJgWiE1c2791f2jSS5NJJBlGx7pmsrk4UiDfasb/Wd70DKQSIKBoeAonEJcCCZF4yg5WRWFo9Cy6C1CrqAxpTEtU4OhEEAPGokAE+jYXE2kNxwM2VdEggWByhMBnYSAgMjfoCCegB8E4cEBYcGBwcBmAExS5cOBQWbCQIahpWZmo0SjwAFQwcIUwhvqRIHDgEKdAALiLIwtBurYwUIwBUEB8S+WpcTCGwfDITT1CofqxMEhS0JD97f4IwTc+MO2YUJAcYV2BIKiOsH2xJVTWMNP+uO0AsBSNBmDjyoMFCVrgebSEirRi1hsC7EAKiRkCBOozIUGQWgcwkgsEc0CRgIEEXgiz4MGODdSENgo74FBB7gIjBLn44GBW3q3PGMnsedQD0sIKUkqNERAwakOTohAgA7AA==" alt="" />,且首项为aaarticlea/gif;base64,R0lGODlhJgASALMAAP///wAAAO7u7piYmGZmZoiIiMzMzDIyMkRERNzc3BAQECIiInZ2dlRUVKqqqrq6uiH5BAEAAAAALAAAAAAmABIAAASwEEgxpL04azBEJlsoTuBVGNcwFE01AgLyYE9xHRfjCoG7JbrADIOTqC4EhEXReAGEmYJDgkhseD4RFGNoAhQhhtK5xYC/Ggeh4SEPMQFAYhEyKFCv8mUhmIsaZyN6FnwCgRINeAAMAVaCbxdnhwkBU4hxeZBLVI4SDG2GNnJsG4MAXUZZAAUMLJanCqoCYgEHDIqrljFOEq9ORZ64Ir4jD6olIwVtLwLIFhQvxCIdFhEAOwA=" alt="" />
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll x,y,fx,fy,a,b;
int main()
{
x=fx=;y=fy=;
for(int i=;i<;i++)
{
a=fx*x+*fy*y;
b=fy*x+fx*y;
printf("%10lld%10lld\n",b,(a-)/);
fx=a;
fy=b;
}
return ;
}
POJ 1320 Street Numbers(佩尔方程)的更多相关文章
- POJ 1320 Street Numbers Pell方程
http://poj.org/problem?id=1320 题意很简单,有序列 1,2,3...(a-1),a,(a+1)...b 要使以a为分界的 前缀和 和 后缀和 相等 求a,b 因为序列很 ...
- POJ 1320 Street Numbers 【佩尔方程】
任意门:http://poj.org/problem?id=1320 Street Numbers Time Limit: 1000MS Memory Limit: 10000K Total Su ...
- POJ 1320 Street Numbers 解佩尔方程
传送门 Street Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2529 Accepted: 140 ...
- POJ 1320:Street Numbers
Street Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2753 Accepted: 1530 De ...
- POJ1320 Street Numbers【佩尔方程】
主题链接: http://poj.org/problem?id=1320 题目大意: 求解两个不相等的正整数N.M(N<M),使得 1 + 2 + - + N = (N+1) + - + M.输 ...
- HDU 3292 【佩尔方程求解 && 矩阵快速幂】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=3292 No more tricks, Mr Nanguo Time Limit: 3000/1000 M ...
- Poj 2247 Humble Numbers(求只能被2,3,5, 7 整除的数)
一.题目大意 本题要求写出前5482个仅能被2,3,5, 7 整除的数. 二.题解 这道题从本质上和Poj 1338 Ugly Numbers(数学推导)是一样的原理,只需要在原来的基础上加上7的运算 ...
- 2010辽宁省赛G(佩尔方程)
#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm& ...
- POJ 1320
作弊了--!该题可以通过因式分解得到一个佩尔方程....要不是学着这章,估计想不到.. 得到x1,y1后,就直接代入递推式递推了 x[n]=x[n-1]*x[1]+d*y[n-1]*y[1] y[n] ...
随机推荐
- Android解决ScrollView视图导致其底部的布局栏被推到上边的问题
近期有个xml布局文件,我说下大概意思: <ScrollView> ...... </ScrollView> <RelativeLayout> ...... < ...
- DateForamt和SimpleDateFormat
1.因为DateFormat是抽象类,所以只能用子类来初始化 DateFormat df = new SimpleDateFormat("yyyy--MM--dd HH:MM:ss,属于本年 ...
- MyBatis数据持久化(八)sql复用
在mybatis中,我们可以將sql语句中公共的部分提取出来,然后需要该段sql的地方通过include标签引入即可,这样可以达到sql语句复用的目的. 例如我们有两条相似的查询语句: <sel ...
- (转载)7个去伪存真的JavaScript面试题
7个去伪存真的JavaScript面试题 上周,我发表了<C#程序员的7个面试问题>.这次我要说的是如何淘汰那些滥竽充数的JavaScript程序员. 作者:小峰来源:码农网|2015-0 ...
- C# 分隔字符串成为字符串数组的方法(保留分隔符)
要求如下: source string: mmmmmmynameismickeym separator: m result string []: {"m", "m&quo ...
- Github上值得关注的前端项目-转自好友trigkit4
http://microjs.com/# 该网站的资源都托管到了github,microjs.com是一个可以让你选择微型的js类库的网站,该网站里的js库都是压缩后不大于5KB的,非常实用 http ...
- Java XSSF 导出excel 工具类
参数解释: title:导出excel标题.headers 导出到excel显示的列头. columns 对应数据库字段 .list 导出数据1.pox中添加依赖 <dependency> ...
- 关于python return 和 print 的区别
概念上一个是 返回值 一个是打印输出 区别一:return是结束语一般放在函数的最后,当你在return 结束后面再写一些东西是不执行的如 下 def renshu(x,y): h=x+y pri ...
- ActiveMQ:JMS开源框架入门介绍
介绍基本的JMS概念与开源的JMS框架ActiveMQ应用,内容涵盖一下几点: 基本的JMS概念 JMS的消息模式 介绍ActiveMQ 一个基于ActiveMQ的JMS例子程序 一:JMS基本概念 ...
- Linux 文件系统的层次化结构
FHS,Filesystem Hierarchy Standard,文件系统层次化标准.这是一个推荐标准,可以从 http://www.pathname.com/fhs/ 获取. 本文不讨论 FHS, ...