当前位置:网站首页>C language I want to pass
C language I want to pass
2022-06-30 01:31:00 【Martin の Blog】

Algorithm design ideas
- First , If there is any in the input sample, except PAT The rest of the characters , Procedure considered as NO
- secondly , about “aPbATca” When ‘c’ and ‘a’ All are empty characters ,‘b’ yes ‘A’ character , It can be judged that :“PAAT” That's right.
- Last , The rest of the characters can be judged by formula inference :P front A The number of * P and T middle A The number of = T after A The number of , If this formula is satisfied, it is also right
- Combined with the idea of appeal, start the implementation of the code
Code
#include <stdio.h>
int main(){
char a[10][100] = {
0};
int n,i,j,count_A,count_P,count_T,s1,s2,s3;
scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%s", &a[i]);
}
for(i=0; i<n; i++){
j=0, count_A=0, count_P=0, count_T=0, s1=0, s2=0, s3=0;
while(a[i][j] != '\0'){
if(a[i][j]=='A'){
count_A++;
}else if(a[i][j]=='P'){
count_P++;
s1 = j;
}else if(a[i][j]=='T'){
count_T++;
s2 = j;
}else{
s3 = 1;
break;
}
j++;
}
if(s3!=1 && count_P==1 && count_T==1 && !((s2-s1-1)*s1-(count_A-s2+1)) && (s2-s1-1)){
printf("YES");
}else{
printf("NO");
}
if(i != n-1){
printf("\n");
}
}
return 0;
}
Running results

边栏推荐
- Varnish 基础概览6
- Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object
- MySQL monitoring
- JS reverse request parameter encryption:
- ctfshow 大赛原题 680-695
- Sentinel source code analysis Part 6 - sentinel adapter module Chapter 4 zuul2 gateway
- Chiffrement des cookies 8
- Pytorch中transforms的用法整理
- C语言 数组元素循环右移问题
- Spark 离线开发框架设计与实现
猜你喜欢

Tetris game based on STM32F103

Cookie encryption 8

Cookie encryption 10

Cookie加密12

MES管理系统功能模块之质量管理

一文读懂,MES管理系统模块功能

JS prototype and prototype chain (Lantern Festival meal)

R language linear regression model fitting diagnosis outliers analysis of domestic gas consumption and calorie examples with self-test questions

js返回内容被unicode编码

js内容混淆,返回内容加密
随机推荐
Unity2D--给动画添加关键帧并绑定事件
Varnish foundation overview 7
R语言线性回归模型拟合诊断异常值分析家庭燃气消耗量和卡路里实例带自测题
【机器学习Q&A】余弦相似度、余弦距离、欧式距离以及机器学习中距离的含义
Kubernetes 核心对象概览详解
Mysql 监控6
MySQL monitoring 1
C language final without failing (Part 1)
Resizekit2.net size and resolution independent
Cookie加密15 登录加密
首届·技术播客月开播在即
How to seamlessly transition from traditional microservice framework to service grid ASM
Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object
Mysql 监控1
MySQL function
Seata 与三大平台携手编程之夏,百万奖金等你来拿
(1)基础学习——图解pin、pad、port、IO、net 的区别
Cookie加密13
Precautions for postoperative fundus hemorrhage / / must see every day
Pytroch Learning Notes 6: NN network layer convolution layer