当前位置: 首页 > news >正文

Codeforces Round 1028 (Div. 2)A题

题目

A. Gellyfish and Tricolor Pansy

time limit per test 1 second

memory limit per test 256 megabytes

Gellyfish and Flower are playing a game called "Duel".

Gellyfish has a HP, while Flower has b HP.

Each of them has a knight. Gellyfish's knight has c HP, while Flower's knight has d HP.

They will play a game in rounds until one of the players wins. For k=1,2,…in this order, they will perform the following actions:

       If k is odd and Gellyfish's knight is alive:Gellyfish's knight can attack Flower and reduce b by 1. If b≤0, Gellyfish wins. Or,Gellyfish's knight can attack Flower's knight and reduce d by 1. If d≤0, Flower's knight dies.

      If k is even and Flower's knight is alive:Flower's knight can attack Gellyfish and reduce a by 1. If a≤0, Flower wins. Or,Flower's knight can attack Gellyfish's knight and reduce c by 1. If c≤0, Gellyfish's knight dies.

As one of the smartest people in the world, you want to tell them who will win before the game. Assume both players play optimally.

It can be proven that the game will never end in a draw. That is, one player has a strategy to end the game in a finite number of moves.

Input

Each test contains multiple test cases. The first line contains the number of test cases t(1≤t≤104). The description of the test cases follows.The first and only line of each test case contains four integers a, b, c, d (1≤a,b,c,d≤109) — the HP of Gellyfish, the HP of Flower, the HP of Gellyfish's knight, and the HP of Flower's knight, respectively.

Output

For each test case, if Flower will win, output "Flower", otherwise output "Gellyfish".

题目解析

G和F分别先后攻击,直至一方胜利。

G工地当轮次是奇数攻击,F则是偶数。攻击是骑士发动攻击可以攻击对方本身或者对方的骑士。

如果本身先死或者骑士死去(丢失攻击的能力)则必定输,攻击方肯定赢。

所以肯定是攻击值更小的一方,对于G攻击min(F,F's knight),F也是一样。如果最小的值一样大小则G赢,因为G是先攻击的一方。

代码

#include<bits/stdc++.h>
using namespace std;
int a, b, c, d;int main()
{int t;cin >> t;int min1, min2;while(t--){cin >> a >> b >> c >> d;min1 = min(a, c);min2 = min(b, d);if(min1 >= min2)cout << "Gellyfish" << endl;else{cout << "Flower" << endl;}}return 0;
}

相关文章:

  • 鸿蒙OSUniApp离线优先数据同步实战:打造无缝衔接的鸿蒙应用体验#三方框架 #Uniapp
  • LeetCode 131.分割回文串:回溯法与回文子串判定的结合
  • MySQ-8.42 MGR 组复制部署及详解
  • 【华为云Astro】从OBS CSV文件获取配置指南
  • uni-app学习笔记十七-css和scss的使用
  • ARINC818编解码设计FPGA实现
  • AR/MR实时光照阴影开发教程
  • mybatis02
  • CSS篇-6
  • pycharm打印时不换行,方便对比观察
  • 多线程( Thread)
  • 【深度学习】 19. 生成模型:Diffusion Models
  • 81、使用DTU控制水下灯光控制
  • ZLG ZCANPro,ECU刷新,bug分享
  • 刚出炉热乎的。UniApp X 封装 uni.request
  • 鸿蒙OS在UniApp中集成Three.js:打造跨平台3D可视化应用#三方框架 #Uniapp
  • 一键净化Excel数据:高性能Python脚本实现多核并行清理
  • uni-app学习笔记二十--pages.json页面路由pages设置
  • 五、单元测试-概述入门
  • 【Python Cookbook】文件与 IO(二)
  • 什么网站有教做变蛋的/线上卖货平台有哪些
  • 网站制作软件都是什么软件/磁力王
  • 网站建设成都市/站长工具一区
  • 网站制作软件/小红书网络营销策划方案
  • 做网站分几步/独立站seo
  • 三线城市做网站需求/百度服务中心人工客服电话