https://www.acmicpc.net/problem/1459 1459๋ฒ: ๊ฑท๊ธฐ ์ธ์ค์ด๋ ํ๊ต์์ ์ง์ผ๋ก ๊ฐ๋ ค๊ณ ํ๋ค. ๋์์ ํฌ๊ธฐ๋ ๋ฌดํ๋์ด๊ณ , ๋์์ ์ธ๋ก ๋๋ก๋ ๋ชจ๋ ์ ์ x์ขํ๋ง๋ค ์๊ณ , ๊ฐ๋ก ๋๋ก๋ ๋ชจ๋ ์ ์ y์ขํ๋ง๋ค ์๋ค. ์ธ์ค์ด๋ ํ์ฌ (0, 0)์ ์๋ค. ๊ทธ๋ฆฌ๊ณ ( www.acmicpc.net import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long x = sc.nextLong(); // ์ง์ ์์น x์ขํ long y = sc.nextLong(); // ์ง์ ์์น y์ขํ long w = sc.nextLong(); // ๊ฑธ์ด์..
ALGORITHM ๐ค
์๊ณ ๋ฆฌ์ฆ ์ฐ์ต / ์ฝ๋ฉํ ์คํธ ์ค๋นhttps://school.programmers.co.kr/learn/courses/30/lessons/42889 import java.util.*; class Solution { public int[] solution(int N, int[] stages) { Map map = new HashMap(); for (int i = 1; i = i) { all++; if (j == i) { fail++; } } } double per = (double) fail / all; // ์คํจ์จ if(fail == 0 && all == 0) { // ๋ชจ๋ ์ฌ๋๋ค์ด ์๋์กฐ์ฐจ ๋ชปํ ์คํ
์ด์ง๊ฐ ์์ ๋๋ 0์ผ๋ก ์ฒ๋ฆฌ (0 / 0 = NaN ๋ฐฉ์ง) per = 0; } map.put(i, per); // key: ์คํ
์ด์ง, v..
https://school.programmers.co.kr/learn/courses/30/lessons/42840 import java.util.*; class Solution { public int[] solution(int[] answers) { int[] supoza1 = {1, 2, 3, 4, 5}; int[] supoza2 = {2, 1, 2, 3, 2, 4, 2, 5}; int[] supoza3 = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; int[] score = new int[3]; int a = 1; int temp = 0; for (int k : answers) { // ์ํฌ์1 ์ ์ ๊ตฌํ๊ธฐ if (supoza1[temp] == k) { score[0] += a; } te..
https://www.acmicpc.net/problem/25206 25206๋ฒ: ๋์ ํ์ ์ ์ธํ๋ํ๊ต ์ปดํจํฐ๊ณตํ๊ณผ๋ฅผ ์กธ์
ํ๊ธฐ ์ํด์๋, ์ ๊ณตํ์ ์ด 3.3 ์ด์์ด๊ฑฐ๋ ์กธ์
๊ณ ์ฌ๋ฅผ ํต๊ณผํด์ผ ํ๋ค. ๊ทธ๋ฐ๋ฐ ์๋ฟ์ธ, ์นํ์ด๋ ๊น๋นกํ๊ณ ์กธ์
๊ณ ์ฌ๋ฅผ ์์ํ์ง ์์๋ค๋ ์ฌ์ค์ ๊นจ๋ฌ์๋ค! ์น www.acmicpc.net import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double score = 0; // ๊ณผ๋ชฉํ์ double credit = 0; // ํ์ double sum = 0; // ํ์ ์ ์ดํฉ double all = 0; // (ํ์ × ๊ณผ๋ชฉํ์ )์..
https://school.programmers.co.kr/learn/courses/30/lessons/176963 class Solution { public int[] solution(String[] name, int[] yearning, String[][] photo) { int[] answer = new int[photo.length]; for (int i = 0; i < photo.length; i++) { for (int j = 0; j < photo[i].length; j++) { for (int k = 0; k < name.length; k++) { if (name[k].equals(photo[i][j])) { answer[i] += yearning[k]; } } } } return answ..
https://www.acmicpc.net/problem/2675 2675๋ฒ: ๋ฌธ์์ด ๋ฐ๋ณต ๋ฌธ์์ด S๋ฅผ ์
๋ ฅ๋ฐ์ ํ์, ๊ฐ ๋ฌธ์๋ฅผ R๋ฒ ๋ฐ๋ณตํด ์ ๋ฌธ์์ด P๋ฅผ ๋ง๋ ํ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. ์ฆ, ์ฒซ ๋ฒ์งธ ๋ฌธ์๋ฅผ R๋ฒ ๋ฐ๋ณตํ๊ณ , ๋ ๋ฒ์งธ ๋ฌธ์๋ฅผ R๋ฒ ๋ฐ๋ณตํ๋ ์์ผ๋ก P๋ฅผ ๋ง๋ค๋ฉด ๋๋ค www.acmicpc.net 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 = 0; i < t; i++) { int r = sc.nextInt(); String s = sc.next(); Stri..
https://www.acmicpc.net/problem/1037 import java.util.*; public class Main { 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); int answer = arr[0] * arr[arr.length - 1]; System.out.println(answer); } }