编程介的小学生 2020-01-14 21:59 采纳率: 20.5%
浏览 206

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

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?