Age of the Great Voyages

Problem Description
"Age of the Great Voyages", which is also called "Uncharted Waters", is an old PC-game telling an interesting story in the period between the 15-th century and the 17-th century, when European explorers sailed the seas to open new alternative ways to Asia when the Ottoman Empire blocked the land routes.

The story evolves on the search of the seven "Proof of the Conqueror", which are seven ancient artifacts, in seven areas around the world (Northern Europe, Mediterranean, Africa, New World, Indian Ocean, South Asia and East Asia). It is said that having these proofs proves that the sailor is the champion of all sailors. Four sailors unwittingly involved in the struggle of the quest of the search of the Proof of the Conqueror.

• from wikipedia

Li Huamei, an Admiral of Ming Dynasty, is one of the four protagonists in the story. She trys to find the "Proof of the Conqueror" for the revitalization of the motherland. One person's power is limited, so she searches for like-minded people to help her.

When Li's fleet voyages to the New World, she meets an intelligent man - Fernandes and invite him to become a member of the fleet as a staff officer. While Fernandes is a strange man, he requires that he will join only if Li can win in the following game:

At the beginning, there are N piles of coins on the desk, the i-th pile has Pi coins. Then Fernandes and Li take turns to take coins from those piles on the desk according to the following rule: when it is someone's turn to take coins, at first, he/she has to select no more than K (and no less than 1) piles that still have coins arbitrarily, then take arbitrary number (at least 1) of coins from each piles he/she selects. The game is over until all coins are taken, and the winer is the person who takes the last coin.

Fernandes is very familiar with this game, and Li is also very clever. So you can assume that both of them know the best strategy to win the game. Now we know the situation at the beginning, and that Fernandes takes coins first. The question is who will win the game?

Input
The first line of the input is a single integer T, representing the number of test cases. Then the description of these T test cases follows.

The first line of each test cases has two integers: N and K, and in the second line there are N positive integers P1, P2, ..., PN givin the number of coins in each pile at the beginning.

1 ≤ N ≤ 10000
0 ≤ Pi ≤ 2147483647

Output
For each test case, if Fernandes can win the game, output "Fernandes wins"; otherwise output "Li wins" in a single line.

Sample Input
3
15 4
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 1
4 12 8
3 2
23 12 8

Sample Output
Li wins
Li wins
Fernandes wins

Age of the Great Voyages
Problem Description "Age of the Great Voyages", which is also called "Uncharted Waters", is an old PC-game telling an interesting story in the period between the 15-th century and the 17-th century, when European explorers sailed the seas to open new alternative ways to Asia when the Ottoman Empire blocked the land routes. The story evolves on the search of the seven "Proof of the Conqueror", which are seven ancient artifacts, in seven areas around the world (Northern Europe, Mediterranean, Africa, New World, Indian Ocean, South Asia and East Asia). It is said that having these proofs proves that the sailor is the champion of all sailors. Four sailors unwittingly involved in the struggle of the quest of the search of the Proof of the Conqueror. - from wikipedia Li Huamei, an Admiral of Ming Dynasty, is one of the four protagonists in the story. She trys to find the "Proof of the Conqueror" for the revitalization of the motherland. One person's power is limited, so she searches for like-minded people to help her. When Li's fleet voyages to the New World, she meets an intelligent man - Fernandes and invite him to become a member of the fleet as a staff officer. While Fernandes is a strange man, he requires that he will join only if Li can win in the following game: At the beginning, there are N piles of coins on the desk, the i-th pile has Pi coins. Then Fernandes and Li take turns to take coins from those piles on the desk according to the following rule: when it is someone's turn to take coins, at first, he/she has to select no more than K (and no less than 1) piles that still have coins arbitrarily, then take arbitrary number (at least 1) of coins from each piles he/she selects. The game is over until all coins are taken, and the winer is the person who takes the last coin. Fernandes is very familiar with this game, and Li is also very clever. So you can assume that both of them know the best strategy to win the game. Now we know the situation at the beginning, and that Fernandes takes coins first. The question is who will win the game? Input The first line of the input is a single integer T, representing the number of test cases. Then the description of these T test cases follows. The first line of each test cases has two integers: N and K, and in the second line there are N positive integers P1, P2, ..., PN givin the number of coins in each pile at the beginning. 1 ≤ N ≤ 10000 0 ≤ Pi ≤ 2147483647 Output For each test case, if Fernandes can win the game, output "Fernandes wins"; otherwise output "Li wins" in a single line. Sample Input 3 15 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 4 12 8 3 2 23 12 8 Sample Output Li wins Li wins Fernandes wins
Columbus’s bargain 的问题
Columbus's bargain

Java学习的正确打开方式

java中的Static、final、Static final各种用法

linux系列之常用运维命令整理笔录

python学习方法总结(内附python全套学习资料)

Spring Boot 开发微信公众号后台
Hello 各位小伙伴，松哥今天要和大家聊一个有意思的话题，就是使用 Spring Boot 开发微信公众号后台。 很多小伙伴可能注意到松哥的个人网站（http://www.javaboy.org）前一阵子上线了一个公众号内回复口令解锁网站文章的功能，还有之前就有的公众号内回复口令获取超 2TB 免费视频教程的功能（免费视频教程），这两个都是松哥基于 Spring Boot 来做的，最近松哥打算通...

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

2019年11月中国大陆编程语言排行榜
2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
C++知识点 —— 整合（持续更新中）

《奇巧淫技》系列-python！！每天早上八点自动发送天气预报邮件到QQ邮箱

js知识点汇总
1.本门课的作用（JavaScript的作用）所有基于Web的程序开发基础 2.一种计算机客户端脚本语言，主要在Web浏览器解释执行。 3.浏览器中Javascript，用于与用户交互，以及实现页面中各种动态特效 4.在HTML文件中，任何JavaScript代码必须放到&lt;script&gt;标签中 5.把JavaScript代码放到外部文件中，在HTML代码中直接引入该文件(外部文...

Python实例大全（基于Python3.7.4）

python学习之路 - 从入门到精通到大师 文章目录[python学习之路 - 从入门到精通到大师](https://blog.csdn.net/TeFuirnever/article/details/90017382)〇、写在前面3.1.目标3.2.什么是线性数据结构3.3.什么是栈3.4.栈的抽象数据类型3.5.Python实现栈3.6.简单括号匹配3.7.符号匹配3.8.十进制转换成二进制...

Java面试官最爱问的volatile关键字

【C++100问】深入理解理解顶层const和底层const

《C++ Primer》学习笔记（五）：循环、分支、跳转和异常处理语句

shell一文入门通

“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

GitHub标星近1万：只需5秒音源，这个网络就能实时“克隆”你的声音

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...
Python 植物大战僵尸代码实现(2):植物卡片选择和种植

Python3.7黑帽编程——病毒篇（基础篇）

shell脚本基础
shell简介：shell是一种脚本语言，可以使用逻辑判断、循环等语法，可以自定义函数，是系统命令的集合 文章目录shell脚本结构和执行方法shell脚本中date命令的用法 shell脚本结构和执行方法 1.shell脚本开头需要加#!/bin/bash 2.以#开头的行作为注释 3.脚本的名字以.sh结尾，用于区分这是一个shell脚本 4.执行方法有两种： 1）bash test.sh 2...
8年经验面试官详解 Java 面试秘诀

1.两种思维方式在求职面试中，经常会考察这种问题：北京有多少量特斯拉汽车？某胡同口的煎饼摊一年能卖出多少个煎饼？深圳有多少个产品经理？一辆公交车里能装下多少个乒乓球？一个正常成年人有多少根头发？这类估算问题，被称为费米问题，是以科学家费米命名的。为什么面试会问这种问题呢？这类问题能把两类人清楚地区分出来。一类是具有文科思维的人，擅长赞叹和模糊想象，它主要依靠的是人的第一反应和直觉，比如小孩...