ACMICPC Kanpur Regional 4467 — Delete

Revision en1, by wish_me, 2017-08-30 14:12:19

Delete the least number of integers from a given set of integers so that the product of the remaining integers in the set is a perfect square. In case there is more than one solution then find the solution that gives the largest perfect square. Assume that each integer contains five or less number of digits. The total number of integers in the given set is twenty or less. You are required to write a program for a problem as simple as this.

Input The input may contain multiple test cases. For each test case there is a single input line. The line contains the given set of integers. The input terminates with a line containing 0 as input. Output For each test case there is only one output line. The line simply prints the integers to be deleted in ascending order. There are two special cases; print output for these cases as indicated below. Case 1: No integer is to be deleted: Print `0' as output. Case 2: All integers are to be deleted: Print all integers in ascending order. Sample Input 2 3 12 18 24 12 10 15 18 4 12 10 15 10 12 15 0 Sample Output 24 0 10 12 15 10 12 15

https://icpcarchive.ecs.baylor.edu/external/44/4467.pdf

Tags #acmicpc, array, advanced math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English wish_me 2017-08-30 17:31:20 25
en1 English wish_me 2017-08-30 14:12:19 1210 Initial revision (published)