#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
using namespace std;
int a[64];
char str[64][64];
int main ()
{
// freopen ("input", "r", stdin);
// freopen ("output1", "w", stdout);
long long k;
scanf ("%lld", &k);
assert (3LL <= k && k <= 1000000000000000000LL);
k -= 2LL;
int p = 0;
for (; k > 0LL; k /= 6LL)
a[++p] = k % 6LL;
str[0][0] = 'X';
int ind = 1;
if (a[p] == 1) str[0][1] = 'X';
if (a[p] == 2) str[0][1] = str[1][0] = 'X';
if (a[p] == 3) str[0][1] = str[0][2] = str[1][1] = 'X', str[1][2] = 'd', str[2][1] = 'r', ++ind;
if (a[p] == 4) str[0][1] = str[1][0] = str[1][1] = 'X', str[1][2] = 'd', str[2][1] = 'r', ++ind;
if (a[p] == 5) str[0][1] = str[0][2] = str[1][0] = str[1][1] = 'X', str[1][2] = 'd', str[2][1] = 'r', ++ind;
--p;
for (int i = p; i; --i)
{
str[ind][ind] = str[ind][ind + 1] = str[ind + 1][ind] = str[ind + 1][ind + 1] = 'X';
str[ind + 2][ind] = str[ind + 2][ind + 1] = 'r';
str[ind][ind + 2] = str[ind + 1][ind + 2] = 'd';
if (a[i] >= 3)
{
a[i] -= 3;
str[ind + 1][0] = 'X';
}
if (a[i])
{
--a[i];
str[ind + 2][0] = 'X';
}
if (a[i]) str[0][ind + 2] = 'X';
ind += 2;
}
str[ind][ind] = 'r';
++ind;
for (int i = 0; i < ind; ++i)
str[i][ind] = 'd',
str[ind][i] = 'r';
++ind;
printf ("%d %d\n", ind, ind);
// printf ("%d\n", ind);
//str[ind - 2][ind - 3] = 'X';
for (int i = 0; i < ind; ++i, printf ("\n"))
for (int j = 0; j < ind; ++j)
if (str[i][j] == NULL) printf (".");
else printf ("%c", str[i][j]);
return 0;
}
Compilation message
costinland.cpp: In function 'int main()':
costinland.cpp:72:30: warning: NULL used in arithmetic [-Wpointer-arith]
72 | if (str[i][j] == NULL) printf (".");
| ^~~~
costinland.cpp:17:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
17 | scanf ("%lld", &k);
| ~~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct! Your size: 3 |
2 |
Correct |
1 ms |
204 KB |
Correct! Your size: 3 |
3 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
4 |
Correct |
1 ms |
208 KB |
Correct! Your size: 4 |
5 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
6 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
7 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
8 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
9 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct! Your size: 47 |
2 |
Correct |
1 ms |
204 KB |
Correct! Your size: 48 |
3 |
Correct |
1 ms |
204 KB |
Correct! Your size: 49 |
4 |
Correct |
1 ms |
204 KB |
Correct! Your size: 48 |
5 |
Correct |
1 ms |
204 KB |
Correct! Your size: 48 |
6 |
Correct |
1 ms |
204 KB |
Correct! Your size: 49 |
7 |
Correct |
1 ms |
204 KB |
Correct! Your size: 49 |
8 |
Correct |
1 ms |
204 KB |
Correct! Your size: 47 |