Codeforces785A-Anton and Polyhedrons
2017-03-17 19:45
274 查看
Anton and Polyhedrons
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
Tetrahedron. Tetrahedron has 4 triangular faces.
Cube. Cube has 6 square faces.
Octahedron. Octahedron has 8 triangular faces.
Dodecahedron. Dodecahedron has 12 pentagonal faces.
Icosahedron. Icosahedron has 20 triangular faces.
All five kinds of polyhedrons are shown on the picture below:
Anton has a collection of n polyhedrons. One day he decided to know, how many faces his polyhedrons have in total. Help Anton and find
this number!
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) —
the number of polyhedrons in Anton's collection.
Each of the following n lines of the input contains a string si —
the name of the i-th polyhedron in Anton's collection. The string can look like this:
"Tetrahedron" (without quotes), if the i-th
polyhedron in Anton's collection is a tetrahedron.
"Cube" (without quotes), if the i-th
polyhedron in Anton's collection is a cube.
"Octahedron" (without quotes), if the i-th
polyhedron in Anton's collection is an octahedron.
"Dodecahedron" (without quotes), if the i-th
polyhedron in Anton's collection is a dodecahedron.
"Icosahedron" (without quotes), if the i-th
polyhedron in Anton's collection is an icosahedron.
Output
Output one number — the total number of faces in all the polyhedrons in Anton's collection.
Examples
input
output
input
output
Note
In the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces,
tetrahedron has 4 faces and dodecahedron has 12 faces.
In total, they have 20 + 6 + 4 + 12 = 42 faces.
题意:给你n个立方体,问一共有几面
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>
using namespace std;
#define LL long long
const int INF=0x3f3f3f3f;
int main()
{
int n;
string s;
while(~scanf("%d",&n))
{
int sum=0;
for(int i=0;i<n;i++)
{
cin>>s;
if(s=="Tetrahedron") sum+=4;
else if(s=="Icosahedron") sum+=20;
else if(s=="Cube") sum+=6;
else if(s=="Octahedron") sum+=8;
else sum+=12;
}
printf("%d\n",sum);
}
return 0;
}
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
Tetrahedron. Tetrahedron has 4 triangular faces.
Cube. Cube has 6 square faces.
Octahedron. Octahedron has 8 triangular faces.
Dodecahedron. Dodecahedron has 12 pentagonal faces.
Icosahedron. Icosahedron has 20 triangular faces.
All five kinds of polyhedrons are shown on the picture below:
Anton has a collection of n polyhedrons. One day he decided to know, how many faces his polyhedrons have in total. Help Anton and find
this number!
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) —
the number of polyhedrons in Anton's collection.
Each of the following n lines of the input contains a string si —
the name of the i-th polyhedron in Anton's collection. The string can look like this:
"Tetrahedron" (without quotes), if the i-th
polyhedron in Anton's collection is a tetrahedron.
"Cube" (without quotes), if the i-th
polyhedron in Anton's collection is a cube.
"Octahedron" (without quotes), if the i-th
polyhedron in Anton's collection is an octahedron.
"Dodecahedron" (without quotes), if the i-th
polyhedron in Anton's collection is a dodecahedron.
"Icosahedron" (without quotes), if the i-th
polyhedron in Anton's collection is an icosahedron.
Output
Output one number — the total number of faces in all the polyhedrons in Anton's collection.
Examples
input
4 Icosahedron Cube Tetrahedron Dodecahedron
output
42
input
3 Dodecahedron Octahedron Octahedron
output
28
Note
In the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces,
tetrahedron has 4 faces and dodecahedron has 12 faces.
In total, they have 20 + 6 + 4 + 12 = 42 faces.
题意:给你n个立方体,问一共有几面
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>
using namespace std;
#define LL long long
const int INF=0x3f3f3f3f;
int main()
{
int n;
string s;
while(~scanf("%d",&n))
{
int sum=0;
for(int i=0;i<n;i++)
{
cin>>s;
if(s=="Tetrahedron") sum+=4;
else if(s=="Icosahedron") sum+=20;
else if(s=="Cube") sum+=6;
else if(s=="Octahedron") sum+=8;
else sum+=12;
}
printf("%d\n",sum);
}
return 0;
}
相关文章推荐
- A. Anton and Polyhedrons
- 【codeforces 785A】Anton and Polyhedrons
- codeforces round#404(div.2) A. Anton and Polyhedrons
- CodeForces 785A Anton and Polyhedrons
- Codeforces Round #404 (Div. 2) A - Anton and Polyhedrons 水题
- Codeforces Round#404 A. Anton and Polyhedrons
- Codeforces Round #404 (Div. 2) A. Anton and Polyhedrons
- CF 505B(Anton and currency you all know-贪心)
- E. Anton and Tree(缩点+树直径模板)
- Codeforces Anton and Letters
- Codeforces Round #329 (Div. 2) B. Anton and Lines 逆序对
- 【27.91%】【codeforces 734E】Anton and Tree
- 【Codeforces Round 324 (Div 2)E】【贪心 构造】Anton and Ira 全排列交换 最小距离成本
- 【codeforces 734F】Anton and School
- C. Anton and Making Potions 贪心 + 二分
- Codeforces Round #379 (Div. 2) Anton and Chess
- Codeforces Round #379 (Div. 2) A. Anton and Danik
- Codeforces Round #379 (Div. 2) E. Anton and Tree
- Codeforces Round #404 D. Anton and School - 2 (范德蒙恒等式+组合数)
- Codeforces Round #404 (Div. 2) B. Anton and Classes