当前位置:网站首页>1003 I want to pass (20 points)
1003 I want to pass (20 points)
2022-08-11 07:48:00 【dumb bit】
1003 我要通过! (20 分)
题目要求:
代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//輸入
int n = scan.nextInt();
scan.nextLine();
//逐个判断
for (int i = 0; i < n; i++) {
String str = scan.nextLine();
if (check(str)){
System.out.println("YES");
} else{
System.out.println("NO");
}
}
}
private static boolean check(String str){
boolean flag = true;
//Determine if the string contains and only consists ofPAT三个字符组成
String s = str.trim().replaceAll("P", "").replaceAll("A", "").replaceAll("T", "");
if (!"".equals(s)){
flag = false;
}
//判断PT唯一
if (!(str.indexOf("P") == str.lastIndexOf("P") && str.indexOf("T") == str.lastIndexOf("T"))){
flag = false;
}
//判断A的个数
int left = str.indexOf("P");
int mid = str.indexOf("T") - left - 1;
int right = str.endsWith("A") ? str.lastIndexOf("A") - str.indexOf("T") : 0;
if (!(right == left * mid)){
flag = false;
}
//判断P在T的前面
if (str.indexOf("T") - str.indexOf("P") - 1 <= 0){
flag = false;
}
return flag;
}
}
结果:
边栏推荐
- 1002 Write the number (20 points)
- 无服务器+域名也能搭建个人博客?真的,而且很快
- oracle19c does not support real-time synchronization parameters, do you guys have any good solutions?
- 我的创作纪念日丨感恩这365天来有你相伴,不忘初心,各自精彩
- 详述MIMIC 的ICU患者检测时间信息表(十六)
- redis操作
- oracle19c不支持实时同步参数,请教一下大佬们有什么好的解决办法吗?
- Service的两种启动方式与区别
- tf中矩阵乘法
- Edge provides label grouping functionality
猜你喜欢
A used in the study of EEG ultra scanning analysis process
1003 我要通过 (20 分)
【推荐系统】:协同过滤和基于内容过滤概述
Redis source code: how to view the Redis source code, the order of viewing the Redis source code, the sequence of the source code from the external data structure of Redis to the internal data structu
【软件测试】(北京)字节跳动科技有限公司终面HR面试题
TF中的条件语句;where()
【@网络工程师:用好这6款工具,让你的工作效率大翻倍!】
囍楽云任务源码
[Recommender System]: Overview of Collaborative Filtering and Content-Based Filtering
机器学习总结(二)
随机推荐
Redis source code: how to view the Redis source code, the order of viewing the Redis source code, the sequence of the source code from the external data structure of Redis to the internal data structu
Unity底层是如何处理C#的
Daily sql-statistics of the number of professionals (including the number of professionals is 0)
【LaTex-错误和异常】\verb ended by end of line.原因是因为闭合边界符没有在\verb命令所属行中出现;\verb命令的正确和错误用法、verbatim环境的用法
Pytorch模型转ONNX模型
cdc连sqlserver异常对象可能有无法序列化的字段 有没有大佬看得懂的 帮忙解答一下
技能在赛题解析:交换机防环路设置
国密规范 SM2 SM3 SM4
prometheus学习4Grafana监控mysql&blackbox了解
接入网、承载网、核心网是什么,交换机路由器是什么、这个和网络的协议有什么关系呢?
Unity3D 学习路线?
tf.cast(), reduce_min(), reduce_max()
接口测试的基础流程和用例设计方法你知道吗?
Edge 提供了标签分组功能
C语言每日一练——Day02:求最小公倍数(3种方法)
梅科尔工作室——BP神经网络
如何选择专业、安全、高性能的远程控制软件
1003 我要通过 (20 分)
buu—Re(5)
Pico neo3 Unity打包设置