HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50709 - k-ary Strings

Guest
• Discussion of problem (1)

Volume problems

• 50549 - k-Nearest Neighbours (kNN)
• 50676 - Cinema Millennium
• 50678 - The Jumping Rabbit
• 50306 - Beautiful Numbers
• 50700 - Candidates for the Mayor
• 50692 - How much money?
• 50790 - Fire Alarm
• 50710 - Permutations
• 50709 - k-ary Strings
• 50708 - Binary Strings
• 50694 - The Cheapest Flight
• 50996 - Checkers - the shortest path
• 50770 - Average Depth
• 50291 - Postfix Arithmetic Expressions
• 50775 - Balanced Parenthesis
• 50736 - Top N Donors - 2
• 50796 - KNN

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