{"problem":{"name":"J. Juicy Candies","description":{"content":"Alex enjoys eating snacks, in particular candies. Recently he discovered a brand of berry-themed juicy candies, with three flavors: blueberry (B), raspberry (R), and strawberry (S). For brevity, we wo","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10152J"},"statements":[{"statement_type":"Markdown","content":"Alex enjoys eating snacks, in particular candies. Recently he discovered a brand of berry-themed juicy candies, with three flavors: blueberry (B), raspberry (R), and strawberry (S). For brevity, we would, for example, use the term _B-candy_ to refer to blueberry-flavored candy.\n\nAlex has B B-candies, R R-candies, and S S-candies. He now wants to form sequences of candies, such that:\n\nFor each candy sequence, there is a string of length (B + R + S) corresponding to it. If the i-th candy in the sequence is strawberry-flavored, for example, then the i-th character of the string would be _S_. Similarly for blueberry- and raspberry-flavored candies.\n\nBefore enjoying the candies, Alex would like to solve the following challenge: among all strings which corresponds to a candy sequence, what is the K-th lexicographically smallest string?\n\nFor two strings s[1...L] and t[1...L], s is said to be lexicographically smaller than t, if there exists an index i (1 ≤ i ≤ L), such that s[j = t[j]] for 1 ≤ j < i, and s[i < t[i]]. We naturally use the character relation _B_  <  _R_  <  _S_.\n\nThe first and only line of input consists of four space-separated integers B, R, S, and K.\n\nFor all test cases, 1 ≤ B, R, S ≤ 200, 1 ≤ K ≤ 1018.\n\nIf the total number of strings is less than K, output _None_.\n\nOtherwise, output the K-th lexicographically smallest string that corresponds to a candy sequence with B B-candies, R R-candies, and S S-candies.\n\n## Input\n\nThe first and only line of input consists of four space-separated integers B, R, S, and K.For all test cases, 1 ≤ B, R, S ≤ 200, 1 ≤ K ≤ 1018.\n\n## Output\n\nIf the total number of strings is less than K, output _None_.Otherwise, output the K-th lexicographically smallest string that corresponds to a candy sequence with B B-candies, R R-candies, and S S-candies.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ B, R, S \\in \\mathbb{Z}_{\\geq 0} $ denote the counts of B-, R-, and S-candies, respectively.  \nLet $ L = B + R + S $.  \nLet $ \\Sigma = \\{B, R, S\\} $ with lexicographic order $ B < R < S $.  \nLet $ \\mathcal{S}(B, R, S) $ be the set of all strings of length $ L $ over $ \\Sigma $ with exactly $ B $ occurrences of $ B $, $ R $ occurrences of $ R $, and $ S $ occurrences of $ S $.\n\n**Constraints**  \n1. $ 1 \\leq B, R, S \\leq 200 $  \n2. $ 1 \\leq K \\leq 10^{18} $  \n3. $ |\\mathcal{S}(B, R, S)| = \\binom{L}{B, R, S} = \\frac{L!}{B! \\, R! \\, S!} $\n\n**Objective**  \nIf $ \\binom{L}{B, R, S} < K $, output \"None\".  \nOtherwise, output the $ K $-th lexicographically smallest string in $ \\mathcal{S}(B, R, S) $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10152J","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}