ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

2021ICPC江西省赛 H Hearthstone So Easy

2021-11-03 22:59:57  阅读:270  来源: 互联网

标签:player game points So Easy each Hearthstone health card


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;
}

标签:player,game,points,So,Easy,each,Hearthstone,health,card
来源: https://blog.csdn.net/m0_53937785/article/details/121132687

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有