A

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!

扩展式中国剩余定理+斐波那契博弈,先打表找规律,找到必输的情况。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
#define LL long long
LL mi[1100],ai[1100],fb[1100];//mi为要模的数,ai为余数。
map<LL,bool>p;
LL gcd(LL a, LL b)
{
return b == 0 ? a : gcd(b, a%b);
}
void exgcd(LL a, LL b, LL &d, LL &x, LL &y)
{
if(!b)
{
d = a, x = 1, y = 0;
}
else
{
exgcd(b, a%b, d, y, x);
y -= x * (a / b);
}
}
LL CRT(LL l, LL r, LL *mi, LL *ai)
{
LL lcm = 1;
for(LL i = l; i <= r; i++)
lcm = lcm / gcd(lcm, mi[i]) * mi[i];
for(LL i = l+1; i <= r; i++)
{
LL A = mi[l], B = mi[i], d, x, y, c = ai[i] - ai[l];
exgcd(A, B, d, x, y);
if(c % d)
return -1;
LL mod = mi[i] / d;
LL k = ((x * c / d) % mod + mod) % mod;
ai[l] = mi[l] * k + ai[l];
mi[l] = mi[l] * mi[i] / d;
}
if(ai[l] == 0)
return lcm;
return ai[l];
}
int main()
{
LL t,n,i;
scanf("%lld",&t);
for(i=1; i<=t; i++)
scanf("%lld%lld",&mi[i],&ai[i]);
n=CRT(1ll,t,mi,ai);
if(n>1e15||n==-1)
{
printf("Tankernb!");
return 0;
}
fb[1]=2,fb[2]=3;
p[2]=true,p[3]=true;
for(i=3;i<=320;i++)
{
fb[i]=fb[i-1]+fb[i-2];
if(fb[i]>1e15)
break;
p[fb[i]]=true;
}
if(p[n])
printf("Lbnb!");
else printf("Zgxnb!");
return 0;
}

The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 A Who is better?的更多相关文章

  1. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 K题 center

    You are given a point set with nn points on the 2D-plane, your task is to find the smallest number o ...

  2. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 XKC's basketball team

    XKC , the captain of the basketball team , is directing a train of nn team members. He makes all mem ...

  3. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 D Carneginon

    Carneginon was a chic bard. But when he was young, he was frivolous and had joined many gangs. Recen ...

  4. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 C Buy Watermelon

    The hot summer came so quickly that Xiaoming and Xiaohong decided to buy a big and sweet watermelon. ...

  5. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 B so easy

    题目链接:https://nanti.jisuanke.com/t/41384 这题暴力能过,我用的是并查集的思想,这个题的数据是为暴力设置的,所以暴力挺快的,但是当他转移的点多了之后,我觉得还是我这 ...

  6. 计蒜客 41391.query-二维偏序+树状数组(预处理出来满足情况的gcd) (The Preliminary Contest for ICPC Asia Xuzhou 2019 I.) 2019年徐州网络赛)

    query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be rep ...

  7. The Preliminary Contest for ICPC Asia Xuzhou 2019 E XKC's basketball team [单调栈上二分]

    也许更好的阅读体验 \(\mathcal{Description}\) 给n个数,与一个数m,求\(a_i\)右边最后一个至少比\(a_i\)大\(m\)的数与这个数之间有多少个数 \(2\leq n ...

  8. The Preliminary Contest for ICPC Asia Xuzhou 2019

    A:Who is better? 题目链接:https://nanti.jisuanke.com/t/41383 题意: 类似于有N个石子,先手第一次不能拿完,每次后手只能拿 1 到 前一次拿的数量* ...

  9. The Preliminary Contest for ICPC Asia Xuzhou 2019 E. XKC's basketball team

    题目链接:https://nanti.jisuanke.com/t/41387 思路:我们需要从后往前维护一个递增的序列. 因为:我们要的是wi + m <= wj,j要取最大,即离i最远的那个 ...

随机推荐

  1. Python高级特性-迭代器和生成器

    迭代器 Python中可迭代对象(iterable)通俗指可直接作用与For循环的数据对象,如Python中的集合数据类型,字符串(str),列表(list),元组(tuple),集合(set),字典 ...

  2. Python中list(列表)、dict(字典)、tuple(元组)、set(集合)详细介绍

    更新时间:2019.08.10 更新内容: "2.14加入sorted()函数" "2.3"加入一种删除元素的方法 "二.字典"新增1.5, ...

  3. "按钮"组件:<h-button> —— 快应用组件库H-UI

     <import name="h-button" src="../Common/ui/h-ui/basic/c_button"></impo ...

  4. undefined 和 not defined

    概念上的解释: undefined是javascript语言中定义的五个原始类中的一个,换句话说,undefined并不是程序报错,而是程序允许的一个值. not defined是javascript ...

  5. 计算机视觉中的对象检测,Python用几段代码就能实现

    目前计算机视觉(CV)与自然语言处理(NLP)及语音识别并列为人工智能三大热点方向,而计算机视觉中的对象检测(objectdetection)应用非常广泛,比如自动驾驶.视频监控.工业质检.医疗诊断等 ...

  6. 如果这篇文章说不清epoll的本质,那就过来掐死我吧!

    转载自:https://www.toutiao.com/i6683264188661367309/ 目录 一.从网卡接收数据说起 二.如何知道接收了数据? 三.进程阻塞为什么不占用cpu资源? 四.内 ...

  7. PIL库之图片处理

    (1)对图片生成缩略图 from PIL import Image im = Image.open("C:\Users\litchi\Desktop\picture1.jpg") ...

  8. [复现]GXY2019

    前言 当时GXY的时候在复习中,临时抱拂脚,没时间打比赛.就写了一题./(ㄒoㄒ)/~~ babysqli 当时做了写了笔记. 过滤了or,()其中or可以用大小写绕过,可以用order by盲注 第 ...

  9. BUUOJ [BJDCTF 2nd]elementmaster

    [BJDCTF 2nd]elementmaster 进来就是这样的一个界面,然后就查看源代码 转换之后是Po.php,尝试在URL之后加上看看,出现了一个“.“ ....... 迷惑 然后看了wp 化 ...

  10. 初始化 RESTful API 风格的博客系统

    作者:HelloGitHub-追梦人物 文中所涉及的示例代码,已同步更新到 HelloGitHub-Team 仓库 在 HelloDjango 全栈系列教程的第一步--Django博客教程(第二版)中 ...