#1040 有几个PAT (25 分)
代码展示:
chars = input()
count = 0
countP = chars.count("P")
countT = chars.count("T")
"PAT"
tempP = 0
tempT = countT
for char in chars:
if char == 'A':
count += (tempP*tempT)
elif char == 'P':
tempP += 1
elif char == 'T':
tempT -= 1
print(count%1000000007)
测评结果: