A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her dog by leaving her house and randomly turning left or right and walking to the end of the street and back. One night she adds up the street numbers of the houses she passes (excluding her own). The next time she walks the other way she repeats this and finds, to her astonishment, that the two sums are the same. Although this is determined in part by her house number and in part by the number of houses in the street, she nevertheless feels that this is a desirable property for her house to have and decides that all her subsequent houses should exhibit it.
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

There is no input for this program.

Output

Output will consist of 10 lines each containing a pair of numbers, in increasing order with the last number, each printed right justified in a field of width 10 (as shown above).

Sample Input


Sample Output

         6         8
35 49

题意 k号房子分开n栋房子,前k-1栋和等于k+1到第n栋。输出k,n。
网上题解大多瞎XX扯X,证明不完整,推导胡说八道直接给出佩尔方程。我直接暴力打印前几组找到了规律
      6         8
        35        49
       204       288
      1189      1681
到这里我就发现了,
204=35*6-6  288=204+35+49
1189=204*6-35  1681=1189+204+288
a[i]=a[i-1]*6-a[i-2]
b[i]=a[i]+a[i-1]+b[i-1]
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define N 1000010
using namespace std;
typedef long long ll;
int a[11];
int b[11];
int main()
{
// freopen("dataout.txt","w",stdout);
a[0]=6;
a[1]=35;
b[0]=8;
b[1]=49;
printf("%10d%10d\n",6,8);
printf("%10d%10d\n",35,49);
for(int i=2;i<10;i++)
{
a[i]=a[i-1]*6-a[i-2];
b[i]=a[i]+a[i-1]+b[i-1];
int x=a[i],y=b[i];
printf("%10d%10d\n",a[i],b[i]);
} }
 

最新文章

  1. Python PIP安装
  2. 求两圆相交部分面积(C++)
  3. IP地址的组成
  4. python 实现树结构的打印
  5. php开发api接口
  6. c#_错误处理_基础
  7. 使用cvs或svn从sourceforge上获取开源项目的方法[转载]
  8. Python 用IMAP接收邮件
  9. Tomcat+Servlet面试题都在这里
  10. 课堂小记---JavaScript(3)
  11. .NET Core跨平台的奥秘[中篇]:复用之殇
  12. Echarts自定义tootips
  13. [Swift]LeetCode934. 最短的桥 | Shortest Bridge
  14. css3选择器和伪类
  15. mfc添加自定义事件
  16. Jdk_API——1.8和Jdk_API1.6下载分享
  17. Docker镜像管理基础与基于容器的镜像制作示例
  18. 8.C#友元程序集----可访问性相关
  19. JVM虚拟机详解
  20. React文档(二)Hello World

热门文章

  1. (转)Shell脚本之break,continue,和exit区别
  2. LeetCode 441.排列硬币(C++)
  3. windows 7下安装MySQL5.6
  4. jquery中load()加载页面,刷新之后,加载的页面不显示的解决办法
  5. HIbernate基于外键的查询
  6. Java Executors小结
  7. jar包介绍
  8. 在Centos7中安装Docker并实例化Mysql
  9. Java 中的四种引用
  10. Javascript的map与forEach的区别