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;
    }
  • 相关阅读:
    第六章 条件处理
    VS2019配置MKL教程(Windows)
    攻防世界--srm-50
    攻防世界--The_Maya_Society
    攻防世界--re1-100
    BUUCTF--findit
    凯撒加密与解密实现
    BUUCTF--rsa
    正则表达式
    PyQuery详解
  • 原文地址:https://www.cnblogs.com/qscqesze/p/6564172.html
Copyright © 2011-2022 走看看