問題一覧 > 通常問題

No.3649 Top View of Jenga

レベル : / AI推定難易度 : 220 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 77
作問者 : Rino-program / テスター : gomaazarasi 👑 p-adic とある理系大学生の日常
お気に入りにしたユーザー ProblemId : 13689 / 自分の提出
問題文最終更新日: 2026-08-04 17:05:36
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 511 (Div.2) (順位表) の他の問題:

Problem Statement

You are building a tower using $N$ wooden blocks.

Viewed from directly above, the tower is divided into a grid of $3$ rows and $3$ columns, for a total of $9$ cells. The cell in the $i$-th row from the top and the $j$-th column from the left of this grid is denoted by $(i, j)$.

Each block has a size of $3$ cells by $1$ cell and can be rotated freely. Perform the following operations until you run out of blocks.

  • The tower is built by stacking blocks. Level $h = 1, 2, \dots$ is stacked as follows.
    • When $h$ is odd

      • For $j = 1, 2, 3$ in this order, stack $1$ block so that it covers the $3$ cells $ ( 1 , j ) , ( 2 , j ) , ( 3 , j ) $.
        If you run out of blocks along the way, the operation ends at that point.
      • Once all $3$ blocks have been stacked, move on to level $h+1$.
    • When $h$ is even

      • For $i = 1, 2, 3$ in this order, stack $1$ block so that it covers the $3$ cells $ ( i , 1 ) , ( i , 2 ) , ( i , 3 ) $.
        If you run out of blocks along the way, the operation ends at that point.
      • Once all $3$ blocks have been stacked, move on to level $h+1$.

After all $N$ blocks have been stacked, find, for each of the $9$ cells seen from directly above, how many blocks are stacked on it.

Constraints

  • $1 \le N \le 10^{12}$
  • $N$ is an integer.

Input

The input is given from standard input in the following format.

$N$

Output

The output consists of $3$ lines. On the $i$-th line, print the numbers of blocks stacked on cells $(i, 1), (i, 2), (i, 3)$, separated by spaces.

Print a newline at the end.

Note that the answer may not fit in a $32$ bit integer type (such as int).

Sample

Sample 1
Input
1
Output
1 0 0
1 0 0
1 0 0

Block number $1$ is block number $1$ of an odd-numbered level, so it is placed vertically in the left column. Therefore, the $3$ cells of the leftmost column each have $1$ block placed on them.

Sample 2
Input
4
Output
2 2 2
1 1 1
1 1 1

Sample 3
Input
11
Output
4 4 4
4 4 4
3 3 3

Sample 4
Input
1000000000000
Output
333333333334 333333333334 333333333334
333333333333 333333333333 333333333333
333333333333 333333333333 333333333333

Note that the input and output may not fit in a $32$ bit integer type (such as int).

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。