자바 백준 1076번 저항
list에 각 String을 저장 한뒤에 indexOf로 몇번째 위치해 있는지 찾아낸다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
Scanner sc = new Scanner(System.in); | |
ArrayList<String> list = new ArrayList<String>(); | |
list.add("black"); | |
list.add("brown"); | |
list.add("red"); | |
list.add("orange"); | |
list.add("yellow"); | |
list.add("green"); | |
list.add("blue"); | |
list.add("violet"); | |
list.add("grey"); | |
list.add("white"); | |
int num1 = list.indexOf(sc.next())*10; | |
int num2 = list.indexOf(sc.next()); | |
long num3 = list.indexOf(sc.next()); | |
System.out.println((num1+num2)*(long)Math.pow(10,num3)); | |
} | |
} |
'백준 알고리즘 > JAVA' 카테고리의 다른 글
자바 백준 1075번 나누기 (0) | 2018.08.05 |
---|---|
자바 백준 1057번 토너먼트 (0) | 2018.08.05 |
자바 백준 2010번 플러그 (0) | 2018.08.03 |
자바 백준 1912번 연속합 (0) | 2018.08.03 |
자바 백준 1094번 막대기 (0) | 2018.08.03 |