HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50709 - k-ary Strings

Guest
• Discussion of problem (1)

Volume problems

• 50717 - Hurdle Jumping
• 50692 - How much money?
• 50431 - Sultan's Game
• 50429 - Secret Message
• 50818 - Depth Limited BST
• 50386 - Conformity
• 50790 - Fire Alarm
• 50710 - Permutations
• 50709 - k-ary Strings
• 50708 - Binary Strings
• 50694 - The Cheapest Flight
• 50996 - Checkers - the shortest path
• 50770 - Average Depth
• 50796 - KNN
• 50291 - Postfix Arithmetic Expressions
• 50340 - Game 19
• 50836 - Censored

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