본문 바로가기

Problem Solving44

SWEA- 5432 쇠막대기 자르기 ( -무조건 push ) - )인경우 (인경우 import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Stack; public class Stick_cut { static int res=0; public static void main(String[] args) throws FileNotFoundException { System.setIn(new FileInputStream("input/stick.txt")); Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int tc = 1; tc stk = .. 2021. 2. 6.
SWEA- 5215 햄버거 다이어트 주어진 재료들 사이의 최적의 조합을 찾는것이 목적 부분집합 풀이 조합 풀이 둘 다 가능하다. 부분집합과 조합의 의미가 비슷하기때문 (부분집합은 true false값을 부여하여 true인경우만 선택하도록 함->n개중 r개를 뽑는다) (조합의 경우는 n개에서 서로다른 r개를 뽑는경우) 1. import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class HamburgerDiet { static int res=0; static int N,L; static class Jaero{ int point; int cal; public Jaero(.. 2021. 2. 6.
SWEA-1218 괄호 짝짓기 첫번째 풀었을 때 import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Stack; public class Solution { public static void main(String[] args) throws FileNotFoundException { //System.setIn(new FileInputStream("input/괄호짝짓기.txt")); Scanner sc = new Scanner(System.in); int T = 10; for (int tc = 1; tc 2021. 2. 6.
SWEA-1247 최적 경로 N개의 고객을 중복없이 고르는 순열 import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class Route {//static클래스는 원래 클래스 안에 있어야함 static class Point{ public int r; public int c; Point(int r, int c) { this.r = r; this.c = c; } @Override public String toString() { return "Point [r=" + r + ", c=" + c + "]"; } } static int res; static int N;.. 2021. 2. 6.
SWEA-1954 달팽이 숫자 좌표 변경후 값 입력을 재귀함수를 이용하였다. import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class Snail { //오른 아래 왼쪽 위에 static int N,stop; static int[][]arr; static boolean [][] visit; public static void main(String[] args) throws FileNotFoundException { System.setIn(new FileInputStream("input/snail.txt")); Scanner sc = new Scanner(System.in); int T = sc.next.. 2021. 2. 6.
SWEA-1210 Ladder 1 이동 기준 설정이 헷갈리는 문제.. import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class Ladder_1 { //구해야할것: 출발점의 x좌표 //가는방향: 왼쪽 오른쪽 위쪽 static int[] dr = {0,0,-1}; static int[] dc = {-1,1,0}; public static void main(String[] args) throws FileNotFoundException { System.setIn(new FileInputStream("input/ladder_1.txt")); Scanner sc = new Scanner(System.in); //.. 2021. 2. 6.