码迷,mamicode.com
首页 > 其他好文 > 详细

PTA 乙级 1003 我要通过! (20分)

时间:2020-06-25 09:53:59      阅读:89      评论:0      收藏:0      [点我收藏+]

标签:mamicode   lazy   src   and   load   class   通过   count   app   

技术图片

 

 

 1 num = eval(input())
 2 an = []
 3 for i in range(0,num):
 4     str = input()
 5     P = str.count(‘P‘)
 6     T = str.count(‘T‘)
 7     A = str.count(‘A‘)
 8     sum = P+T+A
 9     #print(sum)
10     #print(len(str))
11     if P!=1 or T!=1 or sum!=len(str) or A == 0:
12         an.append(‘NO‘)
13         continue
14     ap = str.find(‘P‘)
15     t = str.find(‘T‘)
16     pt = t - ap - 1
17     ta = len(str) - t - 1
18     if(ap*pt == ta and ap >= 0):
19         an.append(‘YES‘) 
20     else:
21         an.append(‘NO‘)
22 
23 for i in range(0,num):
24     print(an[i])

技术图片

 

PTA 乙级 1003 我要通过! (20分)

标签:mamicode   lazy   src   and   load   class   通过   count   app   

原文地址:https://www.cnblogs.com/SCP-514/p/13190950.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!