{"problem":{"name":"145. Star Wars","description":{"content":"You've traveled across a galaxy far, far away, and you land on a planet with two different alien species. Each alien species counts numbers in a different base. Aliens of the first species count numbe","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10269145"},"statements":[{"statement_type":"Markdown","content":"You've traveled across a galaxy far, far away, and you land on a planet with two different alien species. Each alien species counts numbers in a different base. Aliens of the first species count numbers using base $a$, and aliens of the second species count numbers using base $b$. The base used by most humans is decimal, base 10.\n\nThe two alien species are about to start a war, because they cannot properly communicate in numbers. Your task is to convert a number from the first alien species, in base $a$, into base $b$, in order to avert the impending alien war.\n\nThe first line of input contains two integers $a$ and $b$ less than or equal to 10: the number base used by the first alien species, and the number base used by the second alien species, respectively.\n\nThe second line of input contains a single integer $n$ in base $a$.\n\nOutput $m$: the given integer, converted from base $a$ to base $b$.\n\n## Input\n\nThe first line of input contains two integers $a$ and $b$ less than or equal to 10: the number base used by the first alien species, and the number base used by the second alien species, respectively.The second line of input contains a single integer $n$ in base $a$.\n\n## Output\n\nOutput $m$: the given integer, converted from base $a$ to base $b$.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ a, b \\in \\mathbb{Z} $ with $ 2 \\leq a, b \\leq 10 $ be the source and target bases, respectively.  \nLet $ n $ be a non-negative integer represented in base $ a $ as a string of digits $ d_k d_{k-1} \\dots d_0 $, where each $ d_i \\in \\{0, 1, \\dots, a-1\\} $.\n\n**Constraints**  \n1. $ 2 \\leq a \\leq 10 $  \n2. $ 2 \\leq b \\leq 10 $  \n3. $ n $ is a valid base-$ a $ numeral (no leading zeros unless $ n = 0 $)  \n\n**Objective**  \nConvert $ n $ from base $ a $ to base $ b $:  \nLet $ N = \\sum_{i=0}^{k} d_i \\cdot a^i $ be the decimal value of $ n $.  \nOutput the base-$ b $ representation of $ N $ as a string of digits $ m = e_\\ell e_{\\ell-1} \\dots e_0 $, where $ N = \\sum_{j=0}^{\\ell} e_j \\cdot b^j $ and each $ e_j \\in \\{0, 1, \\dots, b-1\\} $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10269145","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}