WOW_SQR - Wow Square
"Wow Square" This problem is about the perfect square number, given a positive integer n your task is to find two integers x and y that satisfy:
1) x<y≤n. Remember that x is always less than y.
2) x*y is a perfect square. This means that there's a positive integer z such that z*z=a*b.
3) x*y is maximum. Find x*y as large as possible without violating previous rules.
4*) y-x is maximum. If there still multiple solution x,y that satisfy all previous rules, choose x,y with largest y-x.
Input
First line, there's an integer T(1 ≤ T ≤ 10,000) then T cases follow.
Each test case there's an integer n(4 ≤ n ≤ 10,000,000).
Output
For each test case, output x and y with this fotmat: x*y. see the examples for more detail.
Example
Input:
6
4
10
15
20
321
1020
Output:
1*4
4*9
3*12
8*18
245*320
864*1014
Score is length of your code.
See also: Another problem added 'and recommended (new!)' by Tjandra Satria Gunawan
hide comments
Ouditchya Sinha:
2013-06-05 19:14:08
Use long long. :) |
|
VV:
2013-04-29 16:32:39
Can't seem to find anything better than O(sqrt(n)) so that I can use anything other than C :( |
|
Aditya Pande:
2012-12-22 06:51:15
Edit:
|
|
Aditya Pande:
2012-12-18 05:31:44
got Accpeted in 0.00
|
|
XeRoN!X:
2012-12-14 19:00:42
Consider moving it to classical section because there are already lot of shortening problems OR add some more interesting constraints and scoring.
|
Added by: | Tjandra Satria Gunawan |
Date: | 2012-12-14 |
Time limit: | 1s |
Source limit: | 1000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own Problem |