B'day Bash

2.5

15 votes
Problem

Karan has his B'day today so,he invites his friends,relatives for party.But now the problem arises that number of people in the party has increased.So, now Karan want his B'day cake should be given to all people present in the party keeping in mind that each Special person in party should have 100gm, Best friends should have 50gm, friends should have 25gm amount from the original cake.


So now you have to help Karan and you are given X gm of cake which you have to divide in 3 group(Special person,Best Friends,Friends) such that each member of the group get the share not less than as state above.If such division is possible than print total ratio of the cake taken by each group, if not print No.

INPUT

Fist line would be T testcase (T<100) followed by T lines which have Quantity of cake in grams(cake<=constraints are n<=36000000) and number of people in three groups separated by space

OUTPUT

If the division is possible for all group than print amount of cake only not units taken by each group else print No.


If after giving each member there respective amount of cake, than left over cake is to be given to

  1. Special person
  2. Best Friends
  3. Friends

if and only if every person of group get it.If not Print No,order of priority given above should be taken in mind.You can give cake to group as
many time as you can,but keeping in mind the given condition.

Consider the test Case
25 1 1 1
so here only friends will have not other you have to print No.
175 1 1 1
here sf =100,bf=50 and f=25 and there sum(100+50+25=175) so you have to print 100 50 25
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

So in 1st case you are given 1500gm of cake and on dividing this in group

Special Person 100*8=800

Best Friends 50*8=400

Friends 25*2=50

and now left with 250 gm of cake so on dividing this Special and Best friends each member will not get the cake so friends get their share of 50 and now leftover is 200 than again check we will left with 150 and repeatedly doing this at last friends share is 300.


2nd Case

Special Person 100*2=200

Best Friends 50*5=250

Friends 25*7=175

which equals to 200+250+175=625 so answer is No

Editor Image

?