๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

IT Blog405

[Codeforces] 431A: Black Square https://codeforces.com/problemset/problem/431/A Problem - 431A - Codeforces codeforces.com ์ฝ”๋“œ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = ne.. 2020. 3. 7.
ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค[Java] - ์œ„์žฅ(ํ•ด์‹œ) https://programmers.co.kr/learn/courses/30/lessons/42578 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์œ„์žฅ | ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค programmers.co.kr ์ฝ”๋“œ import java.util.*; class Solution { public int solution(String[][] clothes) { HashMap map = new HashMap(); int answer = 1; for(int i=0; i 2020. 3. 6.
[๋ฐฑ์ค€] 1062๋ฒˆ: ๊ฐ€๋ฅด์นจ(์™„์ „ ํƒ์ƒ‰, ๋ฐฑํŠธ๋ž˜ํ‚น) https://www.acmicpc.net/problem/1062 1062๋ฒˆ: ๊ฐ€๋ฅด์นจ ์ฒซ์งธ ์ค„์— ๋‹จ์–ด์˜ ๊ฐœ์ˆ˜ N๊ณผ K๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. N์€ 50๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๊ณ , K๋Š” 26๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜ ๋˜๋Š” 0์ด๋‹ค. ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์— ๋‚จ๊ทน ์–ธ์–ด์˜ ๋‹จ์–ด๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋‹จ์–ด๋Š” ์˜์–ด ์†Œ๋ฌธ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ๊ณ , ๊ธธ์ด๊ฐ€ 8๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 15๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค. ๋ชจ๋“  ๋‹จ์–ด๋Š” ์ค‘๋ณต๋˜์ง€ ์•Š๋Š”๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int .. 2020. 3. 6.
ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค[Java] - ์ „ํ™”๋ฒˆํ˜ธ ๋ชฉ๋ก(ํ•ด์‹œ) https://programmers.co.kr/learn/courses/30/lessons/42577 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ „ํ™”๋ฒˆํ˜ธ ๋ชฉ๋ก | ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ „ํ™”๋ฒˆํ˜ธ๋ถ€์— ์ ํžŒ ์ „ํ™”๋ฒˆํ˜ธ ์ค‘, ํ•œ ๋ฒˆํ˜ธ๊ฐ€ ๋‹ค๋ฅธ ๋ฒˆํ˜ธ์˜ ์ ‘๋‘์–ด์ธ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค ํ•ฉ๋‹ˆ๋‹ค. ์ „ํ™”๋ฒˆํ˜ธ๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์„ ๊ฒฝ์šฐ, ๊ตฌ์กฐ๋Œ€ ์ „ํ™”๋ฒˆํ˜ธ๋Š” ์˜์„์ด์˜ ์ „ํ™”๋ฒˆํ˜ธ์˜ ์ ‘๋‘์‚ฌ์ž…๋‹ˆ๋‹ค. ๊ตฌ์กฐ๋Œ€ : 119 ๋ฐ•์ค€์˜ : 97 674 223 ์ง€์˜์„ : 11 9552 4421 ์ „ํ™”๋ฒˆํ˜ธ๋ถ€์— ์ ํžŒ ์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ๋‹ด์€ ๋ฐฐ์—ด phone_book ์ด solution ํ•จ์ˆ˜์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ์–ด๋–ค ๋ฒˆํ˜ธ๊ฐ€ ๋‹ค๋ฅธ ๋ฒˆํ˜ธ์˜ ์ ‘๋‘์–ด์ธ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์œผ๋ฉด false๋ฅผ ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด true๋ฅผ r programmers.co.kr ์ฝ”๋“œ class Solution { public boolean sol.. 2020. 3. 5.
[๋ฐฑ์ค€] 1748๋ฒˆ: ์ˆ˜ ์ด์–ด ์“ฐ๊ธฐ 1(๊ตฌํ˜„) https://www.acmicpc.net/problem/1748 1748๋ฒˆ: ์ˆ˜ ์ด์–ด ์“ฐ๊ธฐ 1 ์ฒซ์งธ ์ค„์— N(1≤N≤100,000,000)์ด ์ฃผ์–ด์ง„๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int count = 0;// ์ž๋ฆฟ์ˆ˜ int plus = 1;// ์ž๋ฆฟ์ˆ˜์— ๋”ํ•˜๋Š” .. 2020. 3. 5.
[๋ฐฑ์ค€] 1912๋ฒˆ: ์—ฐ์†ํ•ฉ(DP) https://www.acmicpc.net/problem/1912 1912๋ฒˆ: ์—ฐ์†ํ•ฉ ์ฒซ์งธ ์ค„์— ์ •์ˆ˜ n(1 ≤ n ≤ 100,000)์ด ์ฃผ์–ด์ง€๊ณ  ๋‘˜์งธ ์ค„์—๋Š” n๊ฐœ์˜ ์ •์ˆ˜๋กœ ์ด๋ฃจ์–ด์ง„ ์ˆ˜์—ด์ด ์ฃผ์–ด์ง„๋‹ค. ์ˆ˜๋Š” -1,000๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 1,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ •์ˆ˜์ด๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf =.. 2020. 3. 5.
[๋ฐฑ์ค€] 3985๋ฒˆ: ๋กค ์ผ€์ดํฌ(๊ตฌํ˜„, ์‹œ๋ฎฌ๋ ˆ์ด์…˜) https://www.acmicpc.net/problem/3985 3985๋ฒˆ: ๋กค ์ผ€์ดํฌ ๋ฌธ์ œ ์ธ๊ธฐ ํ‹ฐ๋น„ ํ”„๋กœ๊ทธ๋žจ "๋‚˜๋Š” ์š”๋ฆฌ์‚ฌ ์ธ๊ฐ€?"์˜ ์ƒˆ ์‹œ์ฆŒ์ด ์‹œ์ž‘ํ•œ๋‹ค. ์ด๋ฒˆ ์‹œ์ฆŒ์€ ๊ธฐ๋„ค์Šค๋ถ์— ๋“ฑ์žฌ๋  ๋งŒํ•œ ์Œ์‹์„ ๋งŒ๋“œ๋Š” ๊ฒƒ์„ ๋ชฉํ‘œ๋กœ ์ง„ํ–‰ํ•œ๋‹ค. ์ฒซ ๋ฒˆ์งธ ์—ํ”ผ์†Œ๋“œ์— ์ถœ์—ฐํ•˜๋Š” ์š”๋ฆฌ์‚ฌ๋Š” ์ „์„ค์˜ ์š”๋ฆฌ์‚ฌ ๊น€์ƒ๊ทผ์ด๊ณ , ๊ธธ์ด L๋ฏธํ„ฐ์˜ ๋กค ์ผ€์ดํฌ๋ฅผ ๋งŒ๋“ค ๊ฒƒ์ด๋‹ค. ์ƒ๊ทผ์€ ๋ช‡ ์‹œ๊ฐ„๋™์•ˆ ์ง‘์ค‘ํ•ด์„œ ์ผ€์ดํฌ๋ฅผ ๋งŒ๋“ค์—ˆ๊ณ , ์ด์ œ ์ŠคํŠœ๋””์˜ค์˜ ๋ฐฉ์ฒญ๊ฐ N๋ช…์—๊ฒŒ ์ผ€์ดํฌ๋ฅผ ๋‚˜๋ˆ„์–ด ์ฃผ๋ ค๊ณ  ํ•œ๋‹ค. ์ƒ๊ทผ์ด๋Š” ๋กค ์ผ€์ดํฌ๋ฅผ ํŽผ์ณ์„œ 1๋ฏธํ„ฐ ๋‹จ์œ„๋กœ ์ž˜๋ผ ๋†“์•˜๋‹ค. ๊ฐ€์žฅ ์™ผ์ชฝ ์กฐ๊ฐ์ด 1๋ฒˆ, ์˜ค๋ฅธ์ชฝ ์กฐ๊ฐ์ด www.acmicpc.net ์ฝ”๋“œ import java.util.Scanner; public class Main { public static void main(Str.. 2020. 3. 5.
[Codeforces] 509A: Maximum in Table https://codeforces.com/problemset/problem/509/A Problem - 509A - Codeforces codeforces.com ์ฝ”๋“œ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[][] arr = new int[n][n]; if(n == 1) { System.out.println(1); return; } // 1ํ–‰์˜ ๊ฐ’๋“ค์€ 1 ... 0,0 ~ 0,n = 1 for(int i=0; i 2020. 3. 5.
[๋ฐฑ์ค€] 1551๋ฒˆ: ์ˆ˜์—ด์˜ ๋ณ€ํ™”(์ˆ˜ํ•™, ์‹œ๋ฎฌ๋ ˆ์ด์…˜) https://www.acmicpc.net/problem/1551 1551๋ฒˆ: ์ˆ˜์—ด์˜ ๋ณ€ํ™” ์ฒซ์งธ ์ค„์— ์ˆ˜์—ด์˜ ํฌ๊ธฐ N๊ณผ K๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. N์€ 20๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๊ณ , K๋Š” 0๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , N-1๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ์ˆ˜์—ด์ด ‘,’๋กœ ๊ตฌ๋ถ„๋˜์–ด ์ฃผ์–ด์ง„๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws I.. 2020. 3. 4.
[๋ฐฑ์ค€] 1526๋ฒˆ: ๊ฐ€์žฅ ํฐ ๊ธˆ๋ฏผ์ˆ˜(์‹œ๋ฎฌ๋ ˆ์ด์…˜) https://www.acmicpc.net/problem/1526 1526๋ฒˆ: ๊ฐ€์žฅ ํฐ ๊ธˆ๋ฏผ์ˆ˜ ์ฒซ์งธ ์ค„์— N์ด ์ฃผ์–ด์ง„๋‹ค. N์€ 4๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ  1,000,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); // N ๋ถ€ํ„ฐ ๋งŒ์กฑํ•˜๋Š” ์ˆ˜๊นŒ์ง€ ๊ฐ์†Œํ•˜๋ฉด์„œ ์ฐพ๋Š”๋‹ค. for(int i=N; i>=4; i--) { boolean flag = true; int num = i; while(num != 0) { // num์˜ ๋์— ์ž๋ฆฌ๊ฐ€ .. 2020. 3. 4.
๋ฐ˜์‘ํ˜•