• 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;
    }
  • 相关阅读:
    20100420 ~ 20100520 小结与本月计划
    打造第二代测试框架TestDriven 2.0(六)—— 最新测试思路分析
    C# 反射性能测试
    Java 反射与cglib.proxy与cglib.beanmap与直接赋值 性能对比
    Apache Mina 源码分析。
    msn in c#, 最新代码
    20100520 ~ 20100620 小结与本月计划
    messageflow 集成到信息系统 第一阶段 手稿
    flash > AMF > java 的对象映射关系
    我在想:也许.net的基因里面就输给了java
  • 原文地址:https://www.cnblogs.com/qscqesze/p/6564172.html
Copyright © 2020-2023  润新知