题目
{% fold 点击显/隐题目 %}
lls最喜欢的几何图形是正多面体,注意到大自然只存在五种正多面体:
Tetrahedron:有4个三角形面
Cube:有6个正方形面
Octahedron:有8个三角形面
Dodecahedron:有12个五边形面
Icosahedron:有20个三角形面(首字母为i的大写)
如下图所示
有一天lls获得了n个正多面体,他想知道这些多面体一共有多少个面,你能帮助lls吗?
第一行为一个整数n(1≤n≤200000),表示正多面体的数量。
接下来n行,每一行为正多面体的种类,用上面所给的5个英文字符串表示。
注意英文字母大小写是区分的。
输出总面数
样例一:
4
Icosahedron
Cube
Tetrahedron
Dodecahedron
样例二:
3
Dodecahedron
Octahedron
Octahedron
样例一:
42
样例二:
28
题解
对于每一组数据,将输入的字符转换成对应的整数加起来即可
代码
{% fold 点击显/隐代码 %}```cpp lls和多面体 https://github.com/OhYee/sourcecode/tree/master/ACM 代码备份
#include
using namespace std;
const int maxn = 105;
char s[maxn];
int main(){
//freopen("in.txt","r",stdin);
int n;
scanf("%d",&n);
int ans = 0;
for(int i=0;i<n;++i){
scanf("%s",s);
if(s[0]=='T')
ans+=4;
else if(s[0]=='C')
ans+=6;
else if(s[0]=='O')
ans+=8;
else if(s[0]=='D')
ans+=12;
else
ans+=20;
}
printf("%d\n",ans);
return 0;
}
{% endfold %}