問題一覧 > 通常問題

No.1935 Water Simulation

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 127
作問者 : noya2 / テスター : tatyam NatsubiSogan
お気に入りにしたユーザー ProblemId : 7288 / 自分の提出
問題文最終更新日: 2022-05-11 00:24:21
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 343 (順位表) の他の問題:

Problem Statement

There are $4$ containers $1,2,3,4$ with capacities $V_1,V_2,V_3,V_4$. Initially, container $1$ contains water of volume $V_1$, and containers $2,3,4$ contain nothing.

Here, operations $1,2,3,4$ are defined as follows.

  • Operation $1$ : Pour the water in container $1$ into container $2$ until container $2$ becomes full or container $1$ becomes empty.
  • Operation $2$ : Pour the water in container $2$ into container $3$ until container $3$ becomes full or container $2$ becomes empty.
  • Operation $3$ : Pour the water in container $3$ into container $4$ until container $4$ becomes full or container $3$ becomes empty.
  • Operation $4$ : Pour the water in container $4$ into container $1$ until container $1$ becomes full or container $4$ becomes empty.
  • Find the volume of water in each of containers $1,2,3,4$ after performing $N$ operations in the order of operations $1,2,3,4,1,2,3,4,\dots$.

    Constraints

  • All inputs are integers.
  • $1\le V_1,V_2,V_3,V_4\le 100$
  • $1\le N\le 10^{18}$
  • Input

    $V_1$ $V_2$ $V_3$ $V_4$ $N$
    

    Output

    Find the volume of water in each of containers $1,2,3,4$ after performing the $N$ operations, and print them in this order, separated by spaces.

    Sample

    Sample 1
    Input
    2 3 1 2 5
    Output
    0 2 0 0

    Let $(v_1,v_2,v_3,v_4)$ denote the volumes of water in containers $1,2,3,4$.

    Initially the state is $(2,0,0,0)$, and after each operation it changes as $(0,2,0,0)\rightarrow (0,1,1,0)\rightarrow (0,1,0,1)\rightarrow (1,1,0,0) \rightarrow (0,2,0,0)$. After $5$ operations the state is $(0,2,0,0)$, so print this separated by spaces.

    Sample 2
    Input
    9 5 7 4 123
    Output
    1 1 3 4

    Sample 3
    Input
    31 41 59 26 535897932
    Output
    26 0 5 0

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