The Chef and the field
All submissions for this problem are available.
The Chef and his brother own a rectangular field.
Chef’s brother wants to sell the field. He calls the Chef one day and says that if any dimension of the field is a prime number, he will sell the field. He tells him that he will measure the exact dimensions the next morning. The Chef does not want to sell the field. He knows that his brother is adamant and there is no way that he will change his mind. So, he comes up with a plan to save some part of the field. He decides to measure the dimensions of the field in the night. If any dimension was a prime number he would reduce that dimension to the closest non prime number. Now, when the brother will measure the field in the morning, he cannot sell it. Print the area of the reduced field.
You need to perform the above task for a number of test cases.
NOTE: If the dimension cannot be reduced to non prime number, then reduce it to 1.
The first line of input contains the number of test cases, t.
Then t lines follow, each containing 2 positive integers, L and B, the dimensions of the field.
The output contains t lines, each for each test case.
For each test case, print a single integer, the area of the resultant field.
1<= L,B <=1000000
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions