코드업 기초 100제 (91~99)

riyu_·2020년 12월 10일
0

코드업 기초 100제

목록 보기
10/10

1091

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int m = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        long sr = a;
        for(int i=1; i<n; i++){
            sr = sr * m + d;
        }
        System.out.print(sr);
    }
}

1092

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int start = (a > b ? a : b) > c ? (a > b ? a : b) : c;
        int day=start;
        while(day%a!=0 | day%b!=0 | day%c!=0){
            day++;
        }
        System.out.print(day);
    }
}

1093

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] att = new int[23];
        int a;

        for(int i=0; i<23; i++){
            att[i] = 0;
        }
        for(int i=0; i<n; i++){
            a = sc.nextInt();
            att[a-1]++;
        }
        for(int i=0; i<23; i++){
            System.out.print(att[i] + " ");
        }
    }
}

1094

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] att = new int[n];

        for(int i=0; i<n; i++){
            att[i] = sc.nextInt();
        }
        for(int i=n; i>0; i--){
            System.out.print(att[i-1] + " ");
        }
    }
}

1095

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] att = new int[n];
        for(int i=0; i<n; i++){
            att[i] = sc.nextInt();
        }
        int min = att[0];
        for(int i=0; i<n; i++){
            if(att[i] < min){
                min = att[i];
            }
        }
        System.out.print(min);
    }
}

1096

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][] board = new int[19][19];
        for(int i=0; i<19; i++){
            for(int j=0; j<19; j++) {
                board[i][j] = 0;
            }
        }

        int n = sc.nextInt();

        for(int i=0; i<n; i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            board[x-1][y-1] = 1;
        }

        for(int i=0; i<19; i++){
            for(int j=0; j<19; j++) {
               System.out.print(board[i][j] + " ");
            }
            System.out.println();
        }
    }
}

1097

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][] board = new int[19][19];
        for(int i=0; i<19; i++){
            for(int j=0; j<19; j++) {
                board[i][j] = sc.nextInt();
            }
        }
        int x,y;
        int n = sc.nextInt();
        while(n>0){
            x = sc.nextInt();
            y = sc.nextInt();
            for(int j=0; j<19; j++){
                if(board[x-1][j] == 0) board[x-1][j]=1;
                else{board[x-1][j]=0;}
            }
            for(int i=0; i<19; i++){
                if(board[i][y-1] == 0) board[i][y-1]=1;
                else{board[i][y-1]=0;}
            }
            n--;
        }

        for(int i=0; i<19; i++){
            for(int j=0; j<19; j++) {
               System.out.print(board[i][j] + " ");
            }
            System.out.println();
        }
    }
}

1098

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int[][] board = new int[w][h];
        for(int i=0; i<w; i++){
            for(int j=0; j<h; j++){
                board[i][j] = 0;
            }
        }

        int n = sc.nextInt();
        for(int p=0; p<n; p++){
            int l = sc.nextInt();
            int d = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(d==0){ // 막대가 가로
                for(int i=x-1; i<x-1+l; i++){
                    board[x-1][i] = 1;
                }
            }else{
                for(int i=x-1; i<x-1+l; i++){
                    board[i][y-1] = 1;
                }
            }

        }
        for(int i=0; i<w; i++){
            for(int j=0; j<h; j++){
                System.out.print(board[i][j] + " ");
            }
            System.out.println();
        }
    }
}

1099

import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][] board = new int[10][10];
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                board[i][j] = sc.nextInt();
            }
        }

        int i;
        int j;
        int eat = 0;
        int y=1;
        for(i=1; i<9; i++){
            if(eat == 1){
                break;
            }
            for(j=y; j<9; j++){
                if(board[i][j] == 2){
                    board[i][j] = 9;
                    eat = 1;
                    break;
                }else if(board[i][j] == 0){
                    if(board[i][j+1] == 1) {
                        board[i][j] = 9;
                        break;
                    }else{
                        board[i][j] = 9;
                        y = j+1;
                    }

                }
            }
        }

        for(i=0; i<10; i++){
            for(j=0; j<10; j++){
                System.out.print(board[i][j]+ " ");
            }
            System.out.println();
        }
    }
}

0개의 댓글

관련 채용 정보