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. typename 关键字

    1.class关键字的同义词 template <typename T> const T& max(const T& x, const T& y) { return ...

  2. 【做中学】第一个 Go 语言程序:漫画下载器

    原文地址: 第一个 Go 语言程序:漫画下载器: https://schaepher.github.io/2020/04/11/golang-first-comic-downloader 之前学了点 ...

  3. GitHub 热点速览 Vol.16:化身蒙娜丽莎和乔布斯对话

    摘要:妙趣横生,上周的 GitHub 热点的关键词.无论是让你化身为爱因斯坦开启会议脑暴模式 avatarify,还是和上周人人都是抠图师项目的同门项目 3D 照片修复:3d-photo-inpain ...

  4. skynet启动流程及调用服务

     3.基本原理 3.1启动流程  1.skynet-src/skynet_main.c 这个是main()函数所在,主要就是设置一下lua的环境.默认的配置.打开config配置文件,并修改默认配置. ...

  5. linux常用命令--打包和压缩文件

    bunzip2 file1.bz2 解压一个叫做 'file1.bz2'的文件 bzip2 file1 压缩一个叫做 'file1' 的文件 gunzip file1.gz 解压一个叫做 'file1 ...

  6. 【题解】P1972 [SDOI2009]HH的项链 - 树状数组

    P1972 [SDOI2009]HH的项链 声明:本博客所有题解都参照了网络资料或其他博客,仅为博主想加深理解而写,如有疑问欢迎与博主讨论✧。٩(ˊᗜˋ)و✧*。 题目描述 \(HH\) 有一串由各种 ...

  7. RESTFul 设计规范

    REST这个词,是Roy Thomas Fielding博士在他2000年提出的,有兴趣的可以阅读一下他的论文, 论文地址为:http://www.ics.uci.edu/~fielding/pubs ...

  8. python-Django与Apache整合wsgi模块

    1.安装wsgi模块 yum search mod_wsgi yum install -y mod_wsgi 2.会在httpd下有配置文件 cd /etc/httpd/conf.d/wsgi.con ...

  9. Java中Date时间类

    Date:表示特定的瞬间,精确到毫秒. 构造方法: Date():根据当前的默认毫秒值创建日期对象 Date(long date):根据给定的毫秒值创建日期对象 public static void ...

  10. Spark RDD----pyspark第四次作业

    1.pyspark交互式编程 查看群里发的“data01.txt”数据集,该数据集包含了某大学计算机系的成绩,数据格式如下所示: Tom,DataBase,80 Tom,Algorithm,50 To ...