HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Exhaustive search & Backtracking > problem:


50709 - k-ary Strings

Guest
• Discussion of problem (1)

Section problems

• 50715 - Zero Sum
• 50711 - Snail Trails
• 50472 - Minimum Sum Triangle
• 50306 - Beautiful Numbers
• 50716 - All Palindromes
• 50714 - The knight
• 50713 - Castle and the girls
• 50710 - Permutations
• 50709 - k-ary Strings
• 50708 - Binary Strings
• 50996 - Checkers - the shortest path
• Check-Mate
• 50479 - Bit Compressor
• 50486 - Problems and Programmers
• 50712 - Moon algebra
• 50717 - Hurdle Jumping
• 50840 - Tanker trucks

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

k-ary Strings

Question: A k-ary code is a string of code which uses only the only the digits from 0 until k-1. Make a program to Generate all k-ary strings of n-digit.

Input specification
You will be given two integers the length of of k-ary strings (n) and the range of digits (k) where 1 ≤ n ≤ 8 and 2 ≤ k ≤ 5

Output specification
Show all k-ary strings with the length n. Every string starts from 0 and then goes until k-1. Each string is shown in a separate line. No space is used within the characters of a string.

Sample Input I   
 2 3
Sample Input II   
 2 4
Sample Output I   
00
01
02
10
11
12
20
21
22
Sample Output II   
00
01
02
03
10
11
12
13
20
21
22
23
30
31
32
33


Для отправки решений необходимо выполнить вход.

www.contester.ru