程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> something-Smiths Problem

something-Smiths Problem

編輯:編程解疑
Smith's Problem

Description

Computer has greatly released scientists from heavy calculation. Before computer is invented, calculation must be done by hand, which is boring and easy to make mistake. But now, with the help of computer much calculation can be finished within a second.

But one day Professor Smith met a strange problem. He had tried to find the positive solutions of the equation with the following form:
X ^ 2 – N * Y ^ 2 = 1,

in which N is a positive integer. But for many values of N, his poor computer seems cannot find an answer!

"That's strange!" said Professor Smith "There must be something wrong with my program!" And you, the assistant of Professor Smith, are assigned the work to solve the problem.
Input

The input will contain several test cases; each contains a positive integer N (1 <= N <= 10 ^ 8) in a single line.
Output

For each test case, in a line output two positive integers X and Y that satisfy the equation and are smaller than 10 ^ 1000. If there is no such solution, output "No solution!"
Sample Input

52
256
991
Sample Output

649 90
No solution!
379516400906811930638014896080 12055735790331359447442538767

最佳回答:


https://github.com/ffq5050139/ACM-ICPC/blob/master/poj.org/POJ%202427%20Smith%27s%20Problem%20Pell%E6%96%B9%E7%A8%8B.java

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved