题解 CF908A 【New Year and Counting Cards】

这回是真正的题解了

其实思路楼上已经说过,我只是来一发C++的

代码:

1
2
3
4
5
6
7
8
9
10
11
12
#include <bits/stdc++.h>
using namespace std;
string s;
int ans;
bool k[256];//我选择了用桶进行优化,这样减少了代码,也变快了
int main(){
k['a']=k['o']=k['e']=k['i']=k['u']=k['1']=k['3']=k['5']=k['7']=k['9']=true;//打表,需要翻过来的定义为true(1)
cin>>s;
for (int i=0;i<s.size();i++)ans+=(k[s[i]]);//直接进行计算
cout<<ans;
return 0;
}