题解 CF78A 【Haiku】
t162
2019-04-07 09:10:53
蒟蒻迷上了正则,迷上了Python。
题目已经说得很清楚了,`短句的音节数视为这个短句中的元音字母数`,所以使用正则匹配就行了。
```
[a,e,i,o,u]{1} #意思是匹配中括号中字符的任意一个。
```
我们使用re模块的findall函数,分别找到三个字符串所有匹配的字符,分别对每个结果取长度并判断即可。
代码:
```python
import re
s1 = input()
s2 = input()
s3 = input()
if(len(re.findall(r'[a,e,i,o,u]{1}',s1))==5 and len(re.findall(r'[a,e,i,o,u]{1}',s2))==7 and len(re.findall(r'[a,e,i,o,u]{1}',s3))==5):
print('YES')
else:
print("NO")
```