Cutting RecipesProblem code: RECIPE |
All submissions for this problem are available.
The chef has a recipe he wishes to use for his guests, but the recipe will make far more food than he can serve to the guests. The chef therefore would like to make a reduced version of the recipe which has the same ratios of ingredients, but makes less food. The chef, however, does not like fractions. The original recipe contains only whole numbers of ingredients, and the chef wants the reduced recipe to only contain whole numbers of ingredients as well. Help the chef determine how much of each ingredient to use in order to make as little food as possible.
Input
Input will begin with an integer T, the number of test cases. Each test case consists of a single line. The line begins with a positive integer N, the number of ingredients. N integers follow, each indicating the quantity of a particular ingredient that is used.
Output
For each test case, output exactly N space-separated integers on a line, giving the quantity of each ingredient that the chef should use in order to make as little food as possible.
Sample Input
3 2 4 4 3 2 3 4 4 3 15 9 6
Sample Output
1 1 2 3 4 1 5 3 2
Constraints
T≤1002≤N≤50
All ingredient quantities are between 1 and 1000, inclusive.
| Author: | pieguy |
| Date Added: | 12-11-2010 |
| Time Limit: | 2 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

we have to take input from
we have to take input from file or console?
@tashfeen - from the console
@tashfeen - from the console :)
but it is written in the help
but it is written in the help that test ur inputs from file as judges do...
@tashfeen, you may read the
@tashfeen, you may read the FAQ . and you have to take the input from console itself. :)
i m getting wrong answer
i m getting wrong answer though my code is running succesfully for different test cases..
I am getting right answer on
I am getting right answer on TC however a wrong answer here any reason??
How to submit
How to submit
Isn't it weird, after the
Isn't it weird, after the challenge is over, neither can one see the solution, nor submit it to see if it works. Is it fair and sensible?
i agree with amit atleat we
i agree with amit atleat we should know we are right or wrong.