2021ICPC江西省赛 H Hearthstone So Easy

2021/11/3 23:14:07

本文主要是介绍2021ICPC江西省赛 H Hearthstone So Easy,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

H. Hearthstone So Easy

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K

Hearthstone is a turn-based card game. The game flow of each round is: Player 1 draws card ⇒ player 1 plays cards ⇒ player 2 draws card ⇒ player 2 plays cards.

We simplify the game logic as follows:

  • During each player’s draw stage, the player attempts to draw a card from his or her deck.
  • During each player’s playing stage, the player can choose:
  1. to increase his/her health by k points. Note that there is no upper limit on health.
  2. to reduce the opponent’s health by k points.

​ When there are no cards in the player’s card deck, the player will enter a state of fatigue. At this time, the player will increase his/her fatigue value by one every times he/she tries to draw a card, and then deduct the amount of health by th****e fatigue value. The fatigue value of each player is initially 000 points.

pllj and freesin like playing hearthstone very much. In a certain game, both players have no cards in their decks, and both the fatigue points are 000 points, and the health points are both n points. When a player’s health is less than or equal to 000, the player immediately loses the game.

​ At this time, it’s pllj’s turn to draw card. Both players are very smart, so they play the game optimally. Who will be the winner? Please output his name.

输入描述:

The first line contains a single integer t (1≤t≤10^5), which represents the number of data cases.
Each test case is one line containing two positive integers n,k(1≤n,k≤10^9)separated by one whitespace, of which meaning is described before.

输出描述:

For each case of data, output a line of string pllj or freesin to indicate the winner.

Tag: math

Difficulty:5/10


思路:

​ 有一点博弈的思想在里面,首先我们可以想到有四种情况: A加血, B也加血(情况一)、A打B B加血(情况二)、A加血 B打A(情况三)、A打B B打A(情况四); 因为A和B都是相同的血量,所以我们可以发现情况一和四拖疲劳的话肯定是A输(A是先手),而且因为A先吃疲劳,A必然会被B先打死 ; 所以A唯一的赢面就在于能否第一回合斩杀B,否则都是B赢。当然,记得特判只有1血时,A直接暴毙。

AC代码:

#include <iostream>

using namespace std;

int t;

int main() {
	cin >> t;
	while (t --) {
		int n, k;
		cin >> n >> k;
		if (n == 1)  cout << "freesin" << endl;
		else if (1 + k >= n)  cout << "pllj" << endl;
		else  cout << "freesin" << endl;
	}
	return 0;
}


这篇关于2021ICPC江西省赛 H Hearthstone So Easy的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程