Cattle off winter training camp 3 - B

Topic Portal

Meaning of the questions is simple but because of discomfort with mental list of mental and card G card, there is no open B title, or should be able to live?
On the solution to a problem already written very clearly Solution: the
paste official Solution:
Here Insert Picture Description
Then do is a simple decimal to binary conversion on the map then simple changes to get away ... (think this difficult problem in a structure, it is easy to think to think of one patterned way to represent all numbers, and each location has two sources, ponder on it, this problem is not difficult, the difficulty is not open for a few people to write the title ...)
posted the code:

#include <iostream>
#define ll long long
#define MAX 55
using namespace std;
int ans[MAX];
char mp[MAX][MAX];
int len = 0;
void getans(ll k)
{
    while (k)
    {
        ans[len++] = k % 2;
        k /= 2;
    }
}
int main()
{
    ll n;
    cin >> n;
    getans(n);
    cout << len << " " << len + 1 << endl;
    for (int i = 0; i < len; i++)
    {
        for (int j = 0; j < i - 1; j++)
            mp[i][j] = 'D';
        for (int j = i + 2; j < len; j++)
            mp[i][j] = 'R';
        if (i == 0)
        {
            mp[i][i] = 'B';
            mp[i][i + 1] = 'D';
        }
        else
        {
            mp[i][i - 1] = 'R';
            mp[i][i] = 'B';
            mp[i][i + 1] = 'D';
        }
        mp[i][len] = 'D';
    }
    for (int i = 0; i < len; i++)
        if (ans[i] == 1)
            mp[i][i + 1] = 'B';
    for (int i = 0; i < len; i++)
    {
        for (int j = 0; j <= len; j++)
            cout << mp[i][j];
        cout << endl;
    }

    return 0;
}

I am writing this to judge what special 0 ... ... is out of the pit (too dishes)

Published 30 original articles · won praise 9 · views 1299

Guess you like

Origin blog.csdn.net/Zhang_sir00/article/details/104241562