結果
| 問題 | No.3633 Rabbit and turtle |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-21 23:00:29 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| + 7µs | |
| コード長 | 1,047 bytes |
| 記録 | |
| コンパイル時間 | 1,808 ms |
| コンパイル使用メモリ | 335,268 KB |
| 実行使用メモリ | 9,384 KB |
| 最終ジャッジ日時 | 2026-08-21 23:00:33 |
| 合計ジャッジ時間 | 4,043 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
using i128 = __int128_t;
ll powmod(ll x, ll n, ll m) {
ll res = 1;
while (n) {
if (n & 1) res = (i128)res * x % m;
x = (i128)x * x % m;
n >>= 1;
}
return res;
}
void solve() {
ll a, b, d, r;
cin >> a >> b >> d >> r;
{
ll gd = gcd(d, r);
d /= gd, r /= gd;
}
ll t = d + r;
ll da = r * a;
ll db = t * b;
if (da > db) cout << "rabbit\n";
else if (da < db) cout << "turtle\n";
else {
ll dt = powmod(10, 100, t);
if (dt == 0) cout << "tie\n";
else {
if ((r * dt + d) / (r + d) * a < b * dt) cout << "turtle\n";
else cout << "rabbit\n";
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int t = 1;
cin >> t;
while (t--) solve();
}