Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Kth tuple from the combination?

Revision en1, by somnath796, 2022-01-10 15:43:34

Wael wrote on a single paper all different possible tuples (x,y,z) such that 1<=x,y,z<=N.Then ,he sorted them in the following order. First sort in increasing order according to their sum(x,y,z) . If two tuples have same sum ,then the tuple with smaller value of x is put first. Output the Kth tuple from the sequence.

Input 2 1

Output 6

Input 2 3

Output 8

Input 50 67

Output 19

Can anyone explain me the approach?

Tags combinations, backtracking

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English somnath796 2022-01-10 15:47:10 42
en1 English somnath796 2022-01-10 15:43:34 500 Initial revision (published)