CF1741A Compare T-Shirt Sizes 题解
CF1741A Compare T-Shirt Sizes 题解
- 题目
- 链接
- 字面描述
- 题面翻译
- 题目描述
- 输入格式
- 输出格式
- 样例 #1
- 样例输入 #1
- 样例输出 #1
- 代码实现
题目
链接
https://www.luogu.com.cn/problem/CF1741A
字面描述
题面翻译
给定两个字符串 aaa 和 bbb 表示两件衣服的尺码,我们规定:字符串只能由字符 M(中等尺寸)组成或由几个字符 X(可以是 0 个)加上一个字符 S(小尺寸) 或 L(大尺寸) 组成。
你需要比较两件衣服尺码大小,比较方法如下:
- 无论前面有多少个字符 X 的小尺寸,都小于中等尺寸和大尺寸;
- 无论前面有多少个字符 X 的大尺寸,都大于中等尺寸和小尺寸;
- 字符 S 前的字符 X 越多,尺寸越小;
- 字符 L 前的字符 X 越多,尺寸越大。
给定 ttt 组尺寸(1≤t≤1041 \le t \le 10^41≤t≤104),若第一件衣服尺寸大,输出 >
,若第二件衣服尺寸大,输出 <
,否则输出 =
。每组数据换行隔开。
题目描述
Two T-shirt sizes are given: $ a $ and $ b $ . The T-shirt size is either a string M or a string consisting of several (possibly zero) characters X and one of the characters S or L.
For example, strings M, XXL, S, XXXXXXXS could be the size of some T-shirts. And the strings XM, LL, SX are not sizes.
The letter M stands for medium, S for small, L for large. The letter X refers to the degree of size (from eXtra). For example, XXL is extra-extra-large (bigger than XL, and smaller than XXXL).
You need to compare two given sizes of T-shirts $ a $ and $ b $ .
The T-shirts are compared as follows:
- any small size (no matter how many letters X) is smaller than the medium size and any large size;
- any large size (regardless of the number of letters X) is larger than the medium size and any small size;
- the more letters X before S, the smaller the size;
- the more letters X in front of L, the larger the size.
For example:
- XXXS < XS
- XXXL > XL
- XL > M
- XXL = XXL
- XXXXXS < M
- XL > XXXS
输入格式
The first line of the input contains a single integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases.
Each test case consists of one line, in which $ a $ and $ b $ T-shirt sizes are written. The lengths of the strings corresponding to the T-shirt sizes do not exceed $ 50 $ . It is guaranteed that all sizes are correct.
输出格式
For each test case, print on a separate line the result of comparing $ a $ and $ b $ T-shirt sizes (lines “<”, “>” or “=” without quotes).
样例 #1
样例输入 #1
6
XXXS XS
XXXL XL
XL M
XXL XXL
XXXXXS M
L M
样例输出 #1
<
>
>
=
<
>
代码实现
刷一道水题
#include<bits/stdc++.h>
using namespace std;int t;
string a,b;
int main(){cin>>t;while(t--){cin>>a>>b;int lena=a.length(),lenb=b.length();if(a[lena-1]<b[lenb-1]){cout<<">"<<endl;continue;}else if(a[lena-1]>b[lenb-1]){cout<<"<"<<endl;continue;}else{if(a[lena-1]=='L'){if(lena>lenb)cout<<">";else if(lena==lenb)cout<<"=";else cout<<"<";cout<<endl;}else{if(lena>lenb)cout<<"<";else if(lena==lenb)cout<<"=";else cout<<">";cout<<endl; }}}return 0;
}
CF1741A Compare T-Shirt Sizes 题解相关推荐
- 洛谷CF1741A Compare T-Shirt Sizes
写在前面:本文旨在记录个人算法学习(小新一枚) 题意 给定两个字符串 aa 和 bb 表示两件衣服的尺码,我们规定:字符串只能由字符 M(中等尺寸)组成或由几个字符 X(可以是 0 个)加上一个字符 ...
- Compare T-Shirt Sizes
Compare T-Shirt Sizes 传送门 Two T-shirt sizes are given: aa and bb. The T-shirt size is either a strin ...
- mysql 代码怎么优化_MySQL 性能优化的简略办法
mysql 性能优化的简单办法 优化数据库最核心的实际上就是配置参数的调整.本文通过一个简单的参数调整,实现了对拥有一个几十万行表的 group by 优化的例子.通过这个简单的调整,数据库性能有了突 ...
- 敏捷整洁之道 -- 第三章 业务实践
敏捷整洁之道 -- 第三章 业务实践 0. 引子 1. 计划游戏 1.1 三元分析 1.2 故事和点数 1.3 故事 1.4 故事估算 1.5 对迭代进行管理 1.6 速率 2. 小步发布 3. 验收 ...
- 牛客题霸 [比较版本号] C++题解/答案
牛客题霸 [比较版本号] C++题解/答案 题目描述 如果version1 > version2 返回1,如果 version1 < version2 返回-1,不然返回0. 输入的ver ...
- 【Python CheckiO 题解】First Word (simplified)
CheckiO 是面向初学者和高级程序员的编码游戏,使用 Python 和 JavaScript 解决棘手的挑战和有趣的任务,从而提高你的编码技能,本博客主要记录自己用 Python 在闯关时的做题思 ...
- 算法(第四版)C# 习题题解——1.2
写在前面 整个项目都托管在了 Github 上:https://github.com/ikesnowy/Algorithms-4th-Edition-in-Csharp 这一节内容可能会用到的库文件有 ...
- 20201219:力扣219周周赛题解
力扣219周周赛题解 题目 思路与算法 代码实现 复杂度分析 题目 比赛中的配对次数 十-二进制数的最少数目 石子游戏 VII 堆叠长方体的最大高度 思路与算法 比赛中的配对次数 两两比赛,淘汰剩一支 ...
- 【LeetCode题解】排序
1. 排序 排序(sort)是一种常见的算法,把数据根据特定的顺序进行排列.经典的排序算法如下: 冒泡排序(bubble sort) 插入排序(insertion sort) 选择排序(selecti ...
最新文章
- Leetcode 4.28 Tree Easy
- zookeeper集群配置与配置文件详解
- VTK:vtkCubeAxesActor用法实战
- P2486 [SDOI2011]染色(树链剖分+线段树)
- 业务配置开发平台qMISPlat 2.0 产品介绍
- Android之网络请求提示Cleartext HTTP traffic to dev*******.com not permitted
- [c++基本语法]——构造函数初始化列表
- TableLayoutPanel闪烁问题解决
- selenium-行为链-ActionChains-0223
- myeclipse 打包Jar
- # 20155224 第十一周 课堂练习《计算后缀表达式的值》
- 用GDB调试程序(10)──查看运行时数据(1)-转
- Vscode 调试:跟踪局部变量的变化
- 数据库系统概论--精简版
- 曲线拟合——最小二乘法( Ordinary Least Square,OLS)
- 深入理解JAVA中的JNDI注入
- #pragma clang diagnostic ignored 忽略警告
- 【2018】【论文笔记】最后一米太赫——
- 用python进行列联表卡方检验
- java捕捉摄像头画面_在java中捕获来自网络摄像头的图像?
热门文章
- SAP PROXY中切换到ESR浏览模式
- Navicat Premium 15 无法导出excel格式的文件
- Chrome浏览器全屏打开指定网页以及开机自启
- SpringCloud Alibaba之 Sentinel流量防卫兵
- PC机与交换机通信的原理描述
- python控制大疆无人机_大疆睿炽Tello EDU无人机python操控之二——使用Tello-Python-master示例程序控制Tello EDU无人机...
- mfc编程 孙鑫_MFC(文本编程,孙鑫C++第五讲笔记整理) | 学步园
- 福布斯发布2019全球亿万富豪榜:马化腾进入前20名
- 废话中的极品废话 单反对焦系统全解析
- sip客户端源码c语言,SIP协议的VOIP