문제출처: https://www.acmicpc.net/problem/2908



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] input = reader.readLine().split(" ");
        StringBuilder num1 = new StringBuilder();
        StringBuilder num2 = new StringBuilder();
        
        for(int i=; i>=; i--){
            num1.append(input[0].charAt(i));
            num2.append(input[1].charAt(i));
        }
        
        System.out.println(Integer.parseInt(num1.toString()) > Integer.parseInt(num2.toString()) ? num1 : num2);
    }
}
cs


'Algorithm' 카테고리의 다른 글

백준 2941번: 크로아티아 알파벳  (0) 2018.10.20
백준 5622번: 다이얼  (0) 2018.10.20
백준 1316번: 그룹 단어 체커  (0) 2018.10.20
백준 1157번: 단어 공부  (0) 2018.10.20
백준 2675번: 문자열 반복  (0) 2018.10.20

문제 출처: https://www.acmicpc.net/problem/1316



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
29
30
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Main {
    
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        int result = 0;
        
        for(int i=; i<N ; i++){
            String str = reader.readLine();
            ArrayList<Character> strList = new ArrayList<>();  
            
            for(int j=; j<str.length() ; j++){
                if(strList.contains(str.charAt(j)) && strList.get(strList.size()-1!= str.charAt(j)){
                    break;
                }
                else {
                    strList.add(str.charAt(j));
                    if(j==str.length()-1)
                        result++;
                }
            }
        }
    
        System.out.println(result);
    }
}
cs



'Algorithm' 카테고리의 다른 글

백준 5622번: 다이얼  (0) 2018.10.20
백준 2908번: 상수  (0) 2018.10.20
백준 1157번: 단어 공부  (0) 2018.10.20
백준 2675번: 문자열 반복  (0) 2018.10.20
백준 10809번: 알파벳 찾기  (0) 2018.10.20

문제 출처: https://www.acmicpc.net/problem/1157




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
29
30
31
32
33
34
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String input = reader.readLine().toUpperCase();
        int[] arr = new int[26];
        
        for(int i=; i<input.length() ; i++)
            arr[input.charAt(i)-65]++;
        
        int max = 0
        boolean isSame = false;
        int index = 0;
        
        for(int i=; i<arr.length ; i++){
            if(max < arr[i]){
                max = arr[i];
                isSame = false;
                index = i;
            }
            else if(max == arr[i]){
                isSame = true;
            }
        }
        
        if(isSame)
            System.out.println("?");
        else
            System.out.println((char)(index+65));
    }
}
cs



'Algorithm' 카테고리의 다른 글

백준 2908번: 상수  (0) 2018.10.20
백준 1316번: 그룹 단어 체커  (0) 2018.10.20
백준 2675번: 문자열 반복  (0) 2018.10.20
백준 10809번: 알파벳 찾기  (0) 2018.10.20
백준 11654번: 아스키 코드  (0) 2018.10.20

+ Recent posts