After Asgard was destroyed, tanker brought his soldiers to earth, and at the same time took on the important task of protecting the peace of the earth. The best two solders were lb and zgx, were very capable, but they always disliked each other. However, one day they encountered a group of foreign invaders (many, but how many only tanker knew). They were all strong enough to destroy the enemy easily. But they found it too boring, so they agreed to follow some rules to deal with the invaders by taking turns, and if one of them had no enemies when it was his turn, he would later admit that the other man was better.
The rules are as follows:
- zgx takes the first turn. But he cannot destroy all the enemies at the first time;
- after that, the number of enemies that can be destroyed at a time is between 11 enemy and 22 times the number of enemies that the former has just destroyed (including 11 enemy and 22 times the number of enemies that the opponent has just destroyed).
- the winner is the one who agrees to destroy the last enemy. Both zgx and lb are smart, so they only perform actions that are best for them.
To ensure fairness, they found their leader, tanker, to judge, but tanker just wanted people to say he was great, so he didn't want them to decide easily, so he hid the number of intruders in a question:
- there are kk sets of integers aa and bb such that nn ≡ bb (mod aa).
- nn is the minimum positive integer solution satisfying the kk groups aa and bb.
Input
In the first line, input kk, and on lines 22 to k + 1k+1, input kk groups aa and bb.
Output
If lb wins, output "Lbnb!
", if zgx wins, output "Zgxnb!
", if they can't solve, (nn does not exist) , output "Tankernb!
" .
Note:
k\le 10k≤10 ,1< n \le 10^{15}n≤1015
For the sample, n=8n=8,because 8\%5=38%5=3, 8 \%3=28%3=2 and 88 is the smallest possible integer that is fit the requirement.
样例输入复制
2
5 3
3 2
样例输出复制
Lbnb!
一道比较裸的题, 使用excrt算出n的值, 再判断n是否为斐波那契数列中的元素即可。(至于这个博弈..我也不太懂, 队友说的)
#include <bits/stdc++.h>
//#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#ifdef LOCAL
#define debug(x) cout << "[" __FUNCTION__ ": " #x " = " << (x) << "]\n"
#define TIME cout << "RuningTime: " << clock() << "ms\n", 0
#else
#define TIME 0
#endif
#define hash_ 1000000009
#define Continue(x) { x; continue; }
#define Break(x) { x; break; }
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
ll fpow(ll a, ll b, int mod) { ll res = 1; for (; b > 0; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; }
ll exgcd(ll a, ll b, ll& x, ll& y) { if (!b) { x = 1, y = 0; return a; } ll d = exgcd(b, a % b, y, x); y -= (a / b) * x; return d; }
ll mul(ll a, ll b, ll mod)
{
int flag = b < 0 ? 1 : 0;
ll res = 0;
b = abs(b);
while (b)
{
if (b & 1)
res = (res + a) % mod;
b >>= 1;
a = (a + a) % mod;
}
if (flag)
return -res % mod;
else
return res % mod;
}
ll m[N], a[N];
ll CRT(int n)
{
ll x, y;
for (int i = 1; i < n; i++)
{
ll d = exgcd(m[0], m[i], x, y);
ll u = a[i] - a[0];
if (u % d != 0)
return -1;
x = mul(x, u, m[i]) / d;
m[i] /= d;
x = (x % m[i] + m[i]) % m[i];
a[0] += m[0] * x;
m[0] *= m[i];
}
return a[0];
}
ll f[80];
void init()
{
f[1] = 1;
f[2] = 1;
for (int i = 3; i < 80; i++)
f[i] = f[i - 1] + f[i - 2];
}
int main()
{
#ifdef LOCAL
freopen("D:/input.txt", "r", stdin);
#endif
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> m[i] >> a[i];
}
ll ans = CRT(n);
if (ans == -1)
cout << "Tankernb!" << endl, exit(0);
init();
//cout << f[79] << endl;
for (int i = 0; i < 80; i++)
{
if (f[i] == ans)
cout << "Lbnb!" << endl, exit(0);
}
cout << "Zgxnb!" << endl, exit(0);
return TIME;
}