Submit Submissions Statistics

Problem ID: pattern-generator

Time Limit: 1.0 seconds

Memory Limit: 32.0 MB

Difficulty: Medium

Pattern Generator

Description

Write a program that repeatedly reads two numbers n and k and prints all bit patterns of length n with k ones in descending order (when the bit patterns are considered as binary numbers). You may assume that 30 >= n > 0, 8 > k >= 0, and n >= k. The first number in the input gives the number of pairs n and k. The numbers n and k are separated by a single space. Leading zeroes in a bit pattern should be included. See the example below.