Please read the new rule regarding the restriction on the use of AI tools. ×

kaffan_69's blog

By kaffan_69, history, 4 years ago, In English
  • Vote: I like it
  • -6
  • Vote: I do not like it

By kaffan_69, history, 4 years ago, In English

Dedicate Length Nikhil wants to bring sofa(s) to his room. But he wants to dedicate the entire length of the room to the sofa(s) (yes I know he is a bit weird). Now Nikhil's room length is W meters, and when he went to the shop he found out sofas of two types, one of length N and other of length M. Now, let Nikhil know how many sofas of the first and second type he should buy to reduce wastage of space. First minimize the space wastage then, if similar result arises always prefer the sofa with a larger length. In case N==M give preference to second sofa.

Input format The first line contains an integer T, denoting the number of test cases. Each test case contains three integers W,N and M.

Output format For every testcase print two integers a and b, number of sofa of type 1 and 2 respectively.

Constraints: 1<=T<=10 1<=N,M,W<=10000

Example Input 1 24 3 5

Output 3 3

Explanation Nikhil will buy 3 sofas of size 3 and 3 sofa's of size 5.

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it

By kaffan_69, history, 4 years ago, In English

please help me with this greedy problem

D fraction Now Arnab is given a fraction N/D . He is asked to divide the fraction in sum of unique unit fractions where N/D=(1/D1)+(1/D2)+(1/D3)+...+(1/Dn). Now find the value of D1,D2,....,Dn.

if (1/Di)=2 then value of Di=1/2, print it in fraction as 1/2 not as floating point number.

Input format The first line contains an integer T , denoting the number of test cases. For each test case, there are two space-separated integers N and D.

Output format For every testcase on a new line, print space separated values of D1,D2,....,Dn.

Constraints: 1<=T<=10 1<=N,D<=10000

Example Input 1 2 3

Output 2 6

Explanation We know, 2/3=1/2+1/6.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it