이 아파트에 거주를 하려면 조건이 있는데, “a 층의 b 호에 살려면 자신의 아래(a-1)층에 1호부터 b 호까지 사람들의 수의 합만큼 사람들을 데려와 살아야한다” 는 계약 조항을 꼭 지키고 들어와야 한다.

아파트에 비어있는 집은 없고 모든 거주민들이 이 계약 조건을 지키고 왔다고 가정 했을 때, 주어지는 양의 정수 k와 n에 대해 k층에 n호에는 몇 명이 살고 있나를 출력하라. 단, 아파트에는 0층부터 있고 각층에는 1호부터 있으며, 0층에 i호에는 i명이 산다.



2
1
3
2
3

2개 케이스

1층 3호

2층 3호


6
10



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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.*;
 
 
public class Main {
    
    
    
    public static void main(String[] args) {
    
        
        
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine().trim();
        int countTry = Integer.valueOf(input);
        String disInput = "";
        int bSum=0;
        int count=1;
        String output="";
        int[][] arr = new int[15][15];
        
        for(int i=0; i<15 ; i++) {
            arr[0][i] = i+1;
            arr[i][0] = 1;
        }
        
        
        for(int k=0  ; k <countTry ; k++) {
            disInput = sc.nextLine().trim();
            int a = Integer.parseInt(disInput);
            disInput = sc.nextLine().trim();
            int b = Integer.parseInt(disInput);
            
            for(int i=1; i<=a ; i++) {
                
                for(int j=1; j<=b; j++) {
                    
                    arr[i][j]= arr[i][j-1] + arr[i-1][j]; 
                    
                }
                
            }
            
            System.out.println(arr[a][b-1]);
            
        }
        
    }
    
}


'오락기 > codeWar' 카테고리의 다른 글

백준 1924 2007년  (0) 2018.05.25
백준 10250 acm호텔  (0) 2018.05.25
백준 8721267 벌집  (0) 2018.05.25
백준 2438 별찍기  (0) 2018.05.25
백준 2941 크로아티아 알파벳  (0) 2018.05.25

오늘은 2007년 1월 1일 월요일이다. 그렇다면 2007년 x월 y일은 무슨 요일일까? 이를 알아내는 프로그램을 작성하시오.



첫째 줄에 x월 y일이 무슨 요일인지에 따라 SUN, MON, TUE, WED, THU, FRI, SAT중 하나를 출력한다.


1 1



MON

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
35
36
import java.util.*;
 
public class Main{
 
    public static void main(String args[]){
        
        int[] cal =        { 31,  28  ,31 , 30 , 31,    30,  31,  31,  30,  31,  30,  31} ;
        String[] cal2 = { "SUN"  , "MON""TUE""WED""THU""FRI""SAT" };
        
        Scanner sc = new Scanner(System.in);
        
        int t = 0;
        int m = sc.nextInt();
        int d = sc.nextInt();
        
        
        
        for(int i = 0 ; i< m-1 ; i++){
                        
            t +=cal[i];
//            System.out.println(cal[i]);
            
        }
//        System.out.println(t);
//        System.out.println(d);
//        System.out.println();
        t=t+d;
        t=t%7;
        
//        System.out.println(t);
        System.out.println(cal2[t]);
        
    
 
    }
}


'오락기 > codeWar' 카테고리의 다른 글

백준 2755 부녀회장이 될테야  (0) 2018.05.25
백준 10250 acm호텔  (0) 2018.05.25
백준 8721267 벌집  (0) 2018.05.25
백준 2438 별찍기  (0) 2018.05.25
백준 2941 크로아티아 알파벳  (0) 2018.05.25


엘베가 젤 왼쪽

손님들은 1호부터 배정받아야하고

층수가 낮은것부터 채워나간다


테스트 케이스 와 h w n->방번호 를입력 하면 몇호인지 출력


2
6 12 10
30 50 72



402
1203


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
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.*;
 
 
public class Main {
    
    
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine().trim();
        int countTry = Integer.valueOf(input);
        String disInput = "";
        int h=0;
        int w=0;
        int num=0;
        int count=1;
        String output="";
        for(int i=0  ; i <countTry ; i++) {
            
            disInput = sc.nextLine().trim();
            int a = disInput.indexOf(" ");
            int b = disInput.lastIndexOf(" ");
            h = Integer.parseInt(disInput.substring(0, a));
            w = Integer.parseInt(disInput.substring(a+1, b));
            num = Integer.parseInt(disInput.substring(b+1, disInput.length()));
                
            while(num>h) {
                num=num-h;
                count++;
            }
            
            output = num+"";
            
            if(count < 10) {
                output +="0"+count;
            }else {
                output +=count;
            }
            
            System.out.println(output.trim());
            count=1;
        }
    }
    
}
 


'오락기 > codeWar' 카테고리의 다른 글

백준 2755 부녀회장이 될테야  (0) 2018.05.25
백준 1924 2007년  (0) 2018.05.25
백준 8721267 벌집  (0) 2018.05.25
백준 2438 별찍기  (0) 2018.05.25
백준 2941 크로아티아 알파벳  (0) 2018.05.25


일때 방을 지난갯수 표현 13까지는 3개 28까지는 5개



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
35
36
37
38
39
import java.util.*;
 
 
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine().trim();
        
        int a = Integer.valueOf(input);
        int count = 0;
        int com = 1;
//         Math.pow(6, complux);
//        7이하 +1
//        19이하 +2
//        37이하+3
//        61이하 +4
//        각 숫자 차이는 6 , 12 , 18 , 24 순으로 증가 
        
 
        while(true) {
//            System.out.println(com +" 까지  a값은 -> " +a);
            if( a <=  (6*count) + com) {
                break;
            }
            com = (6*count) + com;
            count++;
            
        }
        
        System.out.println(count+1);
        
        
    }
    
        
}
 


'오락기 > codeWar' 카테고리의 다른 글

백준 1924 2007년  (0) 2018.05.25
백준 10250 acm호텔  (0) 2018.05.25
백준 2438 별찍기  (0) 2018.05.25
백준 2941 크로아티아 알파벳  (0) 2018.05.25
백준 5622 다이얼  (0) 2018.05.25

첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제


5
*
**
***
****
*****

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.*;
 
public class Main{
 
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        
        for(int i = 1 ; i <= t ; i ++){
            
            for(int  j = 0 ; j<i ; j++){
                System.out.print("*");
            }
 
            System.out.println();
        }
    }
}


'오락기 > codeWar' 카테고리의 다른 글

백준 10250 acm호텔  (0) 2018.05.25
백준 8721267 벌집  (0) 2018.05.25
백준 2941 크로아티아 알파벳  (0) 2018.05.25
백준 5622 다이얼  (0) 2018.05.25
백준 2908 상수  (0) 2018.05.25
크로아티아 알파벳변경
čc=
ćc-
dz=
ñd-
ljlj
njnj
šs=
žz=

이고 위에 없는 알파벳은 한글자씩 샌다




ljes=njak
6
ddz=z=
3



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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.*;
 
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine().trim();
        String str = input;
//        String str = "nljj";
        int count = str.length();
//        dz
//        lj
//        nj
        
        for(int i=0 ; i<str.length() ; i++) {
            
//            System.out.println(str.charAt(i));
            
            if(str.charAt(i) == '=' || str.charAt(i) == '-') {
                count--;
//                System.out.println("= -  빼기");
            }
            
             
            if( (str.charAt(i) == 'd' && str.length() - i >= 3)  && str.charAt(i+1) == 'z' && str.charAt(i+2)  == '=') {
                count--;
                count--;
                i++;
                i++;
//                System.out.println("dz");
            }
            
            if((str.charAt(i) == 'l' && str.length() - i >= 2) && str.charAt(i+1) == 'j') {
                count--;
                i++;
//                System.out.println("lj");
            }
            if((str.charAt(i) == 'n' && str.length() - i >= 2) && str.charAt(i+1) == 'j') {
                count--;
                i++;
//                System.out.println("nj");
            }
            
            
        }
        System.out.println(count);
        
        
        
    }
    
        
}
 

'오락기 > codeWar' 카테고리의 다른 글

백준 8721267 벌집  (0) 2018.05.25
백준 2438 별찍기  (0) 2018.05.25
백준 5622 다이얼  (0) 2018.05.25
백준 2908 상수  (0) 2018.05.25
백준 1157 단어공부  (0) 2018.05.25


1을 걸려면 총 2초 필요 2로땡기면 3초걸리고 


알파벳 UNUCIC 는 868242고 이때 몇초 걸리는지 표현


UNUCIC
36

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.*;
 
public class Main {
    
    public static void main(String[] args) {
        
        //97~122  아스키 a-z
        //65~90 대문자 A-Z
    
        //숫자 1에 2초 2에 3초
 
        //S가 83
        
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine().trim().toUpperCase();
        String str = input;
        int cul =0;
        int sum=0;
        for(int i=0 ; i <str.length() ;i++) {
//            System.out.println(str.charAt(i));
            cul = (int)str.charAt(i) ;
//            System.out.println(cul);
            if(cul >= 83) {
                cul-=1;
                
                if(cul >= 89) {
                    cul-=1;
                }
            }
            
            cul-=65;
            cul/=3;
//            System.out.println(cul);
            
            cul= cul+3;
//            System.out.println(cul);
 
            sum+=cul;
//            System.out.println("###");
        }
        
        System.out.println(sum);
        
    }
    
        
}
 


'오락기 > codeWar' 카테고리의 다른 글

백준 2438 별찍기  (0) 2018.05.25
백준 2941 크로아티아 알파벳  (0) 2018.05.25
백준 2908 상수  (0) 2018.05.25
백준 1157 단어공부  (0) 2018.05.25
2675 백준 문자열반복  (0) 2018.05.11

숫자 2개를 제시하는데

이 숫자를 거꾸로 읽어서 큰수 표현

734 893

437 vs 398


437

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
35
36
37
38
39
40
import java.util.*;
 
public class Main {
    
    public static void main(String[] args) {
        
        //97~122  아스키 a-z
        //65~90 대문자 A-Z
        
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine().trim().toUpperCase();
        String rever="";
        int div =0;
        for(int i=0 ; i<input.length() ;i++) {
            
            if(input.charAt(i) == ' ') {
                div = i;
            }
            
            rever += input.charAt((input.length()-1)-i);
            
            
        }
//        System.out.println(rever);
        
        input = rever;
        int a1 = Integer.parseInt(input.substring(0, div)); 
        int a2 = Integer.parseInt(input.substring(div+1, input.length())); 
        
        
        System.out.println(a1>a2 ? a1 : a2);
        
        
        
        
    }
    
        
}
 


'오락기 > codeWar' 카테고리의 다른 글

백준 2941 크로아티아 알파벳  (0) 2018.05.25
백준 5622 다이얼  (0) 2018.05.25
백준 1157 단어공부  (0) 2018.05.25
2675 백준 문자열반복  (0) 2018.05.11
백준 10809 알파벳찾기  (0) 2018.05.11

가장 많이 사용된 단어 찾기 여러개일경우 -> ? 대소문자 구분없음

Mississipi


?
zZa
Z

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
35
36
37
38
39
40
41
import java.util.*;
import java.util.Map.Entry;
 
public class Main {
    
    public static void main(String[] args) {
        
        //97~122  아스키 a-z
        //65~90 대문자 A-Z
        
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine().trim().toUpperCase();
        char topChar = 0;
        int topCount = 0;
        Map<Character , Integer> map = new HashMap<>();
        
        for(int i=0; i<str.length() ;i++) {
            
            map.put(str.charAt(i), map.get(str.charAt(i)) == null ?  1  : map.get(str.charAt(i))+1);
        }
        
        
        Iterator<Map.Entry<Character, Integer>> iter =map.entrySet().iterator();
        
        while(iter.hasNext()) {
            
            Entry<Character , Integer> entry = iter.next();
            if(topCount < entry.getValue()) {
                topCount = entry.getValue();
                topChar = entry.getKey();
            }else if(topCount == entry.getValue()) {
                topChar = '?';
            }
            
        }
        
        System.out.println(topChar);
    }
        
}
 


'오락기 > codeWar' 카테고리의 다른 글

백준 5622 다이얼  (0) 2018.05.25
백준 2908 상수  (0) 2018.05.25
2675 백준 문자열반복  (0) 2018.05.11
백준 10809 알파벳찾기  (0) 2018.05.11
백준 11654  (0) 2018.05.11

https://www.acmicpc.net/problem/2675


S를 입력받운후에 R번 반복해 T를 출력


첫번째 줄은 줄수


첫번째 엘리먼트 첫번째껀 횟수 두번째껀 반복해야할 문자열


.input

2
3 ABC
5 /HTP

out

AAABBBCCC
/////HHHHHTTTTTPPPPP


code



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
import java.util.*;
 
public class Main {
    
    public static void main(String[] args) {
        
        //97~122  아스키 a-z
        
        Scanner sc = new Scanner(System.in);
        String count = sc.nextLine().trim();
        String[] input = new String[Integer.parseInt(count)];
        int copyCount = 0;
        String sum="";
        for(int i=0; i< (Integer.parseInt(count)) ; i++) {
            sum="";
            input[i] = sc.nextLine().trim();
            copyCount = Integer.parseInt(input[i].substring(0, 1));
            input[i] = input[i].substring(1, input[i].length()).trim();
            
            for(int j=0 ; j<input[i].length() ;j++) {
                
                for(int k=0; k<copyCount ;k++)    sum += input[i].charAt(j);
                
            }
            
            System.out.println(sum);
        }
        
    }
        
}
 


'오락기 > codeWar' 카테고리의 다른 글

백준 2908 상수  (0) 2018.05.25
백준 1157 단어공부  (0) 2018.05.25
백준 10809 알파벳찾기  (0) 2018.05.11
백준 11654  (0) 2018.05.11
백준 10039  (0) 2018.05.11

+ Recent posts