Nearest Perfect Square


Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type

題目說明

請使用者輸入一個正整數 N,程式需找出與 N 距離最近的平方數(如 1, 4, 9, 16, ...)並輸出該平方數,以及該平方數與 N 的距離。

若與 N 距離最近的平方數有兩個,請輸出較小的平方數。

輸入

輸入一個正整數 N,其中 1 ≤ N ≤ 10000

輸出

第一行輸出最近的平方數
第二行輸出 N 與該平方數的距離(正整數)

範例輸入 #1

30

範例輸出 #1

25
5

範例輸入 #2

50

範例輸出 #2

49
1

Comments

There are no comments at the moment.