백준 2003 투포인터
·
Codding_Test/BaekJoon
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class baeckjoon_2003 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int m = ..
백준 1254 팰린드롬 만들기
·
Codding_Test/BaekJoon
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class baekjoon_1254 { public static void main(String[] args) throws IOException { // readLine 사용 시 예외처리 필수 BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = in.readLine(); int answer = str.length(); for (int i = 0; i < str.length(); i++) { if(isPalind(str.subst..
계산기 프로그램 백준5613
·
Codding_Test/BaekJoon
import java.util.*; public class asdas { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int num = sc.nextInt(); while (true){ String finish = sc.next(); if(finish.equals("=")){ break; }switch (finish){ case "+": num += sc.nextInt(); break; case "-": num-= sc.nextInt(); break; case "*": num*= sc.nextInt(); break; case "/": num /= sc.nextInt(); break; } } System.out.p..
요세푸스 백준(1158)
·
Codding_Test/BaekJoon
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class baekjoon_1158 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); Queue q = new LinkedList(); int n = sc.nextInt(); int k = sc.nextInt(); String answer = ""; for (int i = 1; i
해시해킹 백준(26008)
·
Codding_Test/BaekJoon
import java.util.Scanner; public class baekjoon_26008 { public static void main(String[] args) { // 해시해킹 Scanner sc= new Scanner(System.in); int N = sc.nextInt(); // 3 int M = sc.nextInt(); // 2 int A = sc.nextInt(); // 1 int H = sc.nextInt(); // 1 long answer = 1; for (int i = 0; i < N - 1; i++) { answer = answer * M % 1000000007; } System.out.println(answer); } }
최소, 최대 백준(10818)
·
Codding_Test/BaekJoon
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class arrayMinMax { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] arr = new int[N]; for (int i = 0; i < N; i++) { arr[i] = sc.nextInt(); } Arrays.sort(arr); System.out.println(arr[0] + " " + arr[arr.length - 1]); } }
포스택
·
Codding_Test/BaekJoon
* 스택이란 · 메모리의 스택 영역은 함수의 호출과 관계되는 지역변수, 매개변수, 리턴 값등의 임시데이터를 저장한다. · 스택이란 단어는 ‘차곡 차곡 쌓여진 더미’를 의미한다. · LIFO(Last In First Out, 후입선출) 구조라고도 한다. * 스택의 구조 이해하기 가장 먼저 저장되는 데이터는 스택의 아래 쪽(높은 주소)부터 쌓이고, 다음 저장되는 데이터가 바로 그 위(낮은 주소)에 쌓인다. import java.util.Scanner; import java.util.Stack; public class stack { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); ..