日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

POJ 1320 Street Numbers 解佩尔方程

發布時間:2024/4/17 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 POJ 1320 Street Numbers 解佩尔方程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

傳送門 Street Numbers
Time Limit:?1000MS?Memory Limit:?10000K
Total Submissions:?2529?Accepted:?1406

Description

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 835 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 835 49

Source

New Zealand 1990 Division I,UVA 138 題目要求解1+2+3+...+n=(n+1)+....+m. 要使1+2+3+...+n=(n+1)+....+m.那么n(n+1)/2=(m-n)(n+n+1)/2,即(2m+1)^2-8n^2=1.令x=2m+1,y=n,有x^2-8y^2=1.因此就變成解佩爾方程,而x1=3,y1=1.根據迭代公式: xn=xn-1*x1+d*yn-1*y1 yn=xn-1*y1+yn-1*x1.

已知x1=3,y1=1;

有佩爾方程的迭代公式:x[n]=x[n-1]*x1+d*y[n-1]*y1. ? y[n]=y[n-1]*y1+yn-1]*x1

故有:x[n+1]=3x[n]+8y[n];

? ? ? ? ? ?y[n+1]=x[n]+3y[n];

就可以求出前十組解。 #include<stdio.h> #include<math.h> int main() { int x1=3,y1=1,d=8,x,y,px=3,py=1; for(int i=1;i<=10;i++) { x=x1*px+d*y1*py; y=y1*px+x1*py; printf("%10d%10d\n",y,(x-1)/2); px=x;py=y; } return 0; }

?

Pell方程,由費馬提出,但后來歐拉誤記為佩爾提出,并寫入他的著作中。后人多稱佩爾方程。

設d是正整數,且非平方數。 下面的不定方程稱為佩爾(Pell)方程: (1)一定有無窮多組正整數解 這是初等數論中最經典的內容之一。 推導過程

轉載于:https://www.cnblogs.com/kimsimple/p/7342632.html

總結

以上是生活随笔為你收集整理的POJ 1320 Street Numbers 解佩尔方程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。