일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 프로그래밍 언어론
- useState
- JavaScript
- 백준
- 프로그래머스
- 리액트
- 코딩테스트 고득점 Kit
- 데이터모델링과마이닝
- 자바스크립트
- codesandbox
- 코딩테스트 고득점 Kit 완전탐색
- Java
- 컴퓨터 네트워크
- 리액트 훅
- 장고
- react firebase
- react hook
- 프로그래머스 완전탐색
- design pattern
- 자바
- react
- 코틀린
- useEffect
- 자바 공부
- websocket
- 디자인 패턴
- NextJS
- React JS
- vanillaJS
- 프로그래머스 자바
- Today
- Total
목록Algorithm (90)
기록하는 개발자

https://www.acmicpc.net/problem/1463 1463번: 1로 만들기 첫째 줄에 1보다 크거나 같고, 106보다 작거나 같은 정수 N이 주어진다. www.acmicpc.net import java.util.Scanner; public class Main { static Integer[] dp; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); dp = new Integer[N + 1]; dp[0] = dp[1] = 0; System.out.print(recur(N)); } static int recur(int N) { if (dp[N] == null..

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); if (N == 4 || N == 7) System.out.println(-1); else if (N % 5 == 0) System.out.println(N / 5); else if (N % 5 == 1 || N % 5 == 3) System.out.println((N / 5) + 1); else if (N % 5 == 2 || N % 5 == 4) System.out.println((N / 5) + 2); } }

import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; public class Main { static int[][] checked; //확인 여부 static int[][] map; static int dx[] = {-1,1,0,0}; static int dy[] = {0,0,-1,1}; static int n, count; //정점, 간선개수 static ArrayList list = new ArrayList(); public static int dfs(int row, int col) { checked[row][col] = 1; //확인한 정점을 1로 초기화 for(int i=0;i=0 && ny>=0 &&..

import java.io.*; import java.util.*; public class Main{ static int[][] adjacent= new int[1001][1001]; static boolean[] checked= new boolean[1001]; static int n,m; public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); n = s.nextInt(); m = s.nextInt(); for(int i = 0; i < m; i++) { int x = s.nextInt(); int y = s.nextInt(); adjacent[x][y] = adjacent[y][x] =..

class Solution { public int solution(int n, int[] lost, int[] reserve) { int answer = 0; //n=10일 경우 10-1과 10+1을 확인하므로 all[11]인 12번 째 인덱스 까지 포함하여 초기화 int[] all = new int[n+2]; /* default : 0 -1도난당한 학생 0체육복을 갖고 있는 학생 1여벌이 존재하는 학생 */ //여벌이 있는 학생 1 증가 for (int i : reserve) all[i]++; //잃어버린 학생 1 감소 for (int i : lost) all[i]--; //1부터 n번째 학생까지 탐색 for (int i = 1; i < n+1; i++) { if (all[i] == -1) { //i번..

1. 예제를 통한 규칙 또는 특징 찾기 1, 2, 4로 주어진 예제를 통해 수를 조합 한다. -1) 1과 2, 5와 6, 7과 8이 124 나라의 수로 변환된 결과 각 1씩 차이가 난다. -2) 3의 배수는 4로 끝난다. -3) 3n+1번째 수부터 앞 자리 수가 바뀐다. 2. 해법 도출 위 특징들로 미루어 보아 3진법을 사용함을 알 수 있다. 단, 1, 2, 4만 사용하므로 나머지가 0인 경우 4로 표기한다. 10 진수 124 나라의 숫자 계산 방법 1 1 1*1 2 2 2*1 3 4 (4-1)*1 4 11 (3*1)+(1*1) 5 12 (3*1)+(1*2) 6 14 (3*1)+{1*(4-1)} 7 21 (3*2)+(1*1) 8 22 (3*2)+(1*2) 9 24 (3*2)+{1*(4-1)} 10 41 ..

import java.util.*; class Solution { public int[] solution(int[] array, int[][] commands) { //주어지는 배열 개수와 같은 길이로 answer 배열 크기 초기화 int[] answer = new int[commands.length]; for(int i=0; i

class Solution { static int answer; /* index : 몇 번째 인덱스인지, sum : index까지 총 더한 값 */ public void dfs(int[] numbers,int target,int index,int sum){ /* numbers 배열을 끝까지 탐색한 경우 */ if(index == numbers.length){ if(sum == target) // 총합이 target과 같다면 answer++; // 정답 개수 1 증가 return; } /*배열 탐색 -1) 다음 인덱스(index+1)에서 양수인 numbers[index]를 그대로 더하기 -2) 다음 인덱스(index+1)에서 음수인 numbers[index]를 더하기 */ else { dfs(numbers..