ACM (UVa) : 729


// http://uva.onlinejudge.org/external/7/729.html

#include <iostream>
#include <algorithm>
using namespace std;

int main ()
{
    int dataset;
    scanf ("%d", &dataset);

    bool blank = false;

    while ( dataset-- ) {

        if ( blank )
            printf ("\n");
        blank = true;

        int n;
        int h;

        scanf ("%d %d", &n, &h);

        int a [18] = {0};

        for ( int i = 0; i < h; i++ )
            a [n - 1 - i] = 1;

        do {
            for ( int i = 0; i < n; i++ )
                printf ("%d", a [i]);
            printf ("\n");
        } while (next_permutation (a, a + n));

    }

    return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s