785A - Anton and Polyhedrons

 

 문제

 입력한 다면체는 총 몇 면인가?


 INPUT 정수 n (1 ≤ n ≤ 200000), n개의 다면체 문자열

 OUTPUT 총 면의 수

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
 
public class Polyhedrons {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int sum = 0;
        int n = sc.nextInt();
        
        for(int i=0; i<n; i++){
            String in = sc.next();
            if(in.equals("Tetrahedron")){
                sum = sum + 4;
            } else if(in.equals("Cube")){
                sum = sum + 6;   
            } else if(in.equals("Octahedron")) {
                sum = sum + 8;
            } else if(in.equals("Dodecahedron")) {
                sum = sum + 12;
            } else if(in.equals("Icosahedron")) {
                sum = sum + 20;
            }
        } 
        
        System.out.println(sum);
    }
}
 

 

 

 

 

 polyhedron 다면체

 below 아래에

 tetrahedron 4면체

 cube 6면체

 octahedron 8면체

 dodecahedron 12면체

 icosahedron 20면체

+ Recent posts