問題一覧 > 通常問題

No.3633 Rabbit and turtle

レベル : / AI推定難易度 : 1600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 31
作問者 : 👑 ssmbc2929_bartok / テスター : Unbakedbread
お気に入りにしたユーザー ProblemId : 13368 / 自分の提出
問題文最終更新日: 2026-09-13 22:39:27
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 510 数学まみれコンテスト (順位表) の他の問題:

Problem Statement

A rabbit and a turtle are now going to compete to see how far each can advance in $10^{100}$ turns.
At the start, the distance traveled is $0$ for both the rabbit and the turtle.
The rabbit and the turtle each advance according to the following rules.

  • Rabbit: On the first turn, it advances by $A$ and sets its fatigue to $D$.
    After that, its action on each turn is determined as follows.

    • If its fatigue is greater than $0$, it does not advance, and its fatigue decreases by $R$.
    • If its fatigue is $0$ or less, it advances by $A$, and its fatigue increases by $D$.
  • Turtle: It advances by $B$ every turn.

Determine which of them wins, that is, which of them has traveled the longer distance after $10^{100}$ turns.
Note that a tie is also possible.

You are given $T$ test cases; answer each of them.

Constraints

  • $1 \leqq B \leqq A \leqq 10^{9}$
  • $1 \leqq R \leqq D \leqq 10^{9}$
  • $1 \leqq T \leqq 10^5$
  • All inputs are integers.

Input

$T$
$testcase_1$
$testcase_2$
$\vdots$
$testcase_T$

Each test case is given in the following format.

$A\ B\ D\ R$

Output

For each test case, print rabbit if the rabbit wins, turtle if the turtle wins, and tie if it is a tie. The output consists of $T$ lines.
Print a newline at the end.

Sample

Sample 1
Input
3
3 1 1 1
1 1 2 1
4 2 1 1
Output
rabbit
turtle
tie

Test case $1$ proceeds as follows.

Turn $1$: Since it is the first turn, the rabbit advances by $3$ and sets its fatigue to $1$. The turtle advances by $1$.
Turn $2$: The rabbit recovers $1$ fatigue, bringing it to $0$. The turtle advances by $1$.
In total, the rabbit has advanced $3$ and the turtle has advanced $2$.
Turn $3$: Since the rabbit's fatigue is $0$, it advances by $3$ and sets its fatigue to $1$. The turtle advances by $1$.
In total, the rabbit has advanced $6$ and the turtle has advanced $3$.
Turn $4$: The rabbit recovers $1$ fatigue, bringing it to $0$. The turtle advances by $1$.
In total, the rabbit has advanced $6$ and the turtle has advanced $4$.
Turn $5$: Since the rabbit's fatigue is $0$, it advances by $3$ and sets its fatigue to $1$. The turtle advances by $1$.
In total, the rabbit has advanced $9$ and the turtle has advanced $5$.

From this progression, the rabbit ultimately travels the longer distance.

Also, note that the match can end in a tie, as in test case $3$.

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