zoukankan      html  css  js  c++  java
  • Codeforces Round #404 (Div. 2) A

    A - Anton and Polyhedrons

    题目连接:

    http://codeforces.com/contest/785/problem/A

    Description

    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.

    Sample Input

    4
    Icosahedron
    Cube
    Tetrahedron
    Dodecahedron

    Sample Output

    42

    Hint

    题意

    给你一堆多面体,然后问你总共多少个面。

    题解:

    实际上只需要if if if if就好了嘛

    代码

    #include<bits/stdc++.h>
    using namespace std;
    int n,ans=0;
    string s;
    int main(){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>s;
            if(s=="Tetrahedron")ans+=4;
            if(s=="Cube")ans+=6;
            if(s=="Octahedron")ans+=8;
            if(s=="Dodecahedron")ans+=12;
            if(s=="Icosahedron")ans+=20;
        }
        cout<<ans<<endl;
    }
  • 相关阅读:
    ping命令的几个简单使用
    CentOS下编译安装hping3
    CentOS下安装gns3
    sendip简单使用
    Ubuntu/CentOS使用BIND配置DNS服务器
    远程重启linux主机的几种方法
    使用U盘安装win7系统,遇到“无法定位现有系统分区”问题
    导出csv文件
    Mvc 分页栏扩展方法
    初学HTML5系列三:事件
  • 原文地址:https://www.cnblogs.com/qscqesze/p/6564172.html
Copyright © 2011-2022 走看看