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

IT Blog409

[๋ฐฑ์ค€] 13458๋ฒˆ: ์‹œํ—˜๊ฐ๋… https://www.acmicpc.net/problem/13458 13458๋ฒˆ: ์‹œํ—˜ ๊ฐ๋… ์ฒซ์งธ ์ค„์— ์‹œํ—˜์žฅ์˜ ๊ฐœ์ˆ˜ N(1 ≤ N ≤ 1,000,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ๊ฐ ์‹œํ—˜์žฅ์— ์žˆ๋Š” ์‘์‹œ์ž์˜ ์ˆ˜ Ai (1 ≤ Ai ≤ 1,000,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์…‹์งธ ์ค„์—๋Š” B์™€ C๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ B, C ≤ 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();// ์‹œํ—˜์žฅ ๊ฐœ์ˆ˜ int[] nNum = new int[N]; for(.. 2020. 1. 21.
[๋ฐฑ์ค€] 11651๋ฒˆ: ์ขŒํ‘œ ์ •๋ ฌํ•˜๊ธฐ2 https://www.acmicpc.net/problem/11651 11651๋ฒˆ: ์ขŒํ‘œ ์ •๋ ฌํ•˜๊ธฐ 2 ์ฒซ์งธ ์ค„์— ์ ์˜ ๊ฐœ์ˆ˜ N (1 ≤ N ≤ 100,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์—๋Š” i๋ฒˆ์ ์˜ ์œ„์น˜ xi์™€ yi๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (-100,000 ≤ xi, yi ≤ 100,000) ์ขŒํ‘œ๋Š” ํ•ญ์ƒ ์ •์ˆ˜์ด๊ณ , ์œ„์น˜๊ฐ€ ๊ฐ™์€ ๋‘ ์ ์€ ์—†๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = .. 2020. 1. 20.
[๋ฐฑ์ค€] 10773๋ฒˆ: ์ œ๋กœ https://blog.naver.com/zzang9ha?Redirect=Write&categoryNo=52 https://blog.naver.com/PostWriteForm.nhn?blogId=zzang9ha&Redirect=Write&categoryNo=52&redirect=Write&widgetTypeCall=true blog.naver.com ์ฝ”๋“œ import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Stack stack = new Stack(); int K = scan.nextInt(.. 2020. 1. 20.
[๋ฐฑ์ค€] 2609๋ฒˆ: ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ https://www.acmicpc.net/problem/2609 2609๋ฒˆ: ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ ์ฒซ์งธ ์ค„์—๋Š” ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง„ ๋‘ ์ˆ˜์˜ ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋ฅผ,๋‘˜์งธ ์ค„์—๋Š” ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง„ ๋‘ ์ˆ˜์˜ ์ตœ์†Œ ๊ณต๋ฐฐ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.util.Scanner; public class Main { // ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜ static int GCD(int x, int y) { int result = 0; if(y == 0) return x; else return GCD(y, x%y); } // ์ตœ์†Œ ๊ณต๋ฐฐ์ˆ˜ static int LCD(int x, int y) { int gcd = GCD(x, y); return x*y / gcd;// ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ => ๋‘์ˆ˜์˜ ๊ณฑ / ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ } p.. 2020. 1. 20.
[๋ฐฑ์ค€] 10814๋ฒˆ: ๋‚˜์ด์ˆœ ์ •๋ ฌ https://www.acmicpc.net/problem/10814 10814๋ฒˆ: ๋‚˜์ด์ˆœ ์ •๋ ฌ ์˜จ๋ผ์ธ ์ €์ง€์— ๊ฐ€์ž…ํ•œ ์‚ฌ๋žŒ๋“ค์˜ ๋‚˜์ด์™€ ์ด๋ฆ„์ด ๊ฐ€์ž…ํ•œ ์ˆœ์„œ๋Œ€๋กœ ์ฃผ์–ด์ง„๋‹ค. ์ด๋•Œ, ํšŒ์›๋“ค์„ ๋‚˜์ด๊ฐ€ ์ฆ๊ฐ€ํ•˜๋Š” ์ˆœ์œผ๋กœ, ๋‚˜์ด๊ฐ€ ๊ฐ™์œผ๋ฉด ๋จผ์ € ๊ฐ€์ž…ํ•œ ์‚ฌ๋žŒ์ด ์•ž์— ์˜ค๋Š” ์ˆœ์„œ๋กœ ์ •๋ ฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. www.acmicpc.net ์ฝ”๋“œ import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); // 1) int N = scan.nextInt(); String.. 2020. 1. 20.
[๋ฐฑ์ค€] 2822๋ฒˆ: ์ ์ˆ˜ ๊ณ„์‚ฐ https://www.acmicpc.net/problem/2822 2822๋ฒˆ: ์ ์ˆ˜ ๊ณ„์‚ฐ ๋ฌธ์ œ ์ƒ๊ทผ์ด๋Š” ํ€ด์ฆˆ์‡ผ์˜ PD์ด๋‹ค. ์ด ํ€ด์ฆˆ์‡ผ์˜ ์ฐธ๊ฐ€์ž๋Š” ์ด 8๊ฐœ ๋ฌธ์ œ๋ฅผ ํ‘ผ๋‹ค. ์ฐธ๊ฐ€์ž๋Š” ๊ฐ ๋ฌธ์ œ๋ฅผ ํ’€๊ณ , ๊ทธ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ์„ ๋•Œ ์–ป๋Š” ์ ์ˆ˜๋Š” ๋ฌธ์ œ๋ฅผ ํ’€๊ธฐ ์‹œ์ž‘ํ•œ ์‹œ๊ฐ„๋ถ€ํ„ฐ ๊ฒฝ๊ณผํ•œ ์‹œ๊ฐ„๊ณผ ๋‚œ์ด๋„๋กœ ๊ฒฐ์ •ํ•œ๋‹ค. ๋ฌธ์ œ๋ฅผ ํ’€์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ์—๋Š” 0์ ์„ ๋ฐ›๋Š”๋‹ค. ์ฐธ๊ฐ€์ž์˜ ์ด ์ ์ˆ˜๋Š” ๊ฐ€์žฅ ๋†’์€ ์ ์ˆ˜ 5๊ฐœ์˜ ํ•ฉ์ด๋‹ค. ์ƒ๊ทผ์ด๋Š” ์ž ์‹œ ์—ฌ์ž์นœ๊ตฌ์™€ ์ „ํ™” ํ†ตํ™”๋ฅผ ํ•˜๋Š๋ผ ์ฐธ๊ฐ€์ž์˜ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜์ง€ ์•Š๊ณ  ์žˆ์—ˆ๋‹ค. ์ฐธ๊ฐ€์ž์˜ 8๊ฐœ ๋ฌธ์ œ ์ ์ˆ˜๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ด ์ ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜ www.acmicpc.net ์ฝ”๋“œ import java.util.Arrays; import java.util.Scanner; public class Main { pu.. 2020. 1. 20.
[๋ฐฑ์ค€] 2501๋ฒˆ: ์•ฝ์ˆ˜ ๊ตฌํ•˜๊ธฐ https://www.acmicpc.net/problem/2501 2501๋ฒˆ: ์•ฝ์ˆ˜ ๊ตฌํ•˜๊ธฐ ์ฒซ์งธ ์ค„์— N๊ณผ K๊ฐ€ ๋นˆ์นธ์„ ์‚ฌ์ด์— ๋‘๊ณ  ์ฃผ์–ด์ง„๋‹ค. N์€ 1 ์ด์ƒ 10,000 ์ดํ•˜์ด๋‹ค. K๋Š” 1 ์ด์ƒ N ์ดํ•˜์ด๋‹ค. 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(); int K = scan.nextInt(); int countN = 0;// N์˜ ์•ฝ์ˆ˜ ๊ฐœ์ˆ˜ int index = 0;// K๋ฒˆ์งธ ์ž‘์€์ˆ˜์™€ ํŒ๋ณ„ํ•  ๋ณ€์ˆ˜ int result = 0;// ๊ฒฐ๊ณผ๊ฐ’ for(in.. 2020. 1. 20.
[๋ฐฑ์ค€] 2576๋ฒˆ: ํ™€์ˆ˜ https://www.acmicpc.net/problem/2576 2576๋ฒˆ: ํ™€์ˆ˜ 7๊ฐœ์˜ ์ž์—ฐ์ˆ˜๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ, ์ด๋“ค ์ค‘ ํ™€์ˆ˜์ธ ์ž์—ฐ์ˆ˜๋“ค์„ ๋ชจ๋‘ ๊ณจ๋ผ ๊ทธ ํ•ฉ์„ ๊ตฌํ•˜๊ณ , ๊ณ ๋ฅธ ํ™€์ˆ˜๋“ค ์ค‘ ์ตœ์†Ÿ๊ฐ’์„ ์ฐพ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 7๊ฐœ์˜ ์ž์—ฐ์ˆ˜ 12, 77, 38, 41, 53, 92, 85๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ์ด๋“ค ์ค‘ ํ™€์ˆ˜๋Š” 77, 41, 53, 85์ด๋ฏ€๋กœ ๊ทธ ํ•ฉ์€ 77 + 41 + 53 + 85 = 256 ์ด ๋˜๊ณ , 41 < 53 < 77 < 85 ์ด๋ฏ€๋กœ ํ™€์ˆ˜๋“ค ์ค‘ ์ตœ์†Ÿ๊ฐ’์€ 41์ด ๋œ๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] .. 2020. 1. 20.
[๋ฐฑ์ค€] 2858๋ฒˆ: ๊ธฐ์ˆ™์‚ฌ ๋ฐ”๋‹ฅ https://www.acmicpc.net/problem/2858 2858๋ฒˆ: ๊ธฐ์ˆ™์‚ฌ ๋ฐ”๋‹ฅ ๋ฌธ์ œ ์ƒ๊ทผ์ด๋Š” ๊ธฐ์ˆ™์‚ฌ ์ƒํ™œ์„ ํ•œ๋‹ค. ์ƒ๊ทผ์ด์˜ ๋ฐฉ์˜ ํฌ๊ธฐ๋Š” L*W ์ด๋‹ค. ์ˆ˜์—…์‹œ๊ฐ„์— ํƒ€์ผ ์ฑ„์šฐ๊ธฐ ๊ฒฝ์šฐ์˜ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๋˜ ์ƒ๊ทผ์ด๋Š” ์ž์‹ ์˜ ๋ฐฉ๋„ 1*1ํฌ๊ธฐ ํƒ€์ผ๋กœ ์ฑ„์šฐ๋ ค๊ณ  ํ•œ๋‹ค. ์ด๋•Œ, ๊ฐ€์žฅ์ž๋ฆฌ๋Š” ๋นจ๊ฐ„์ƒ‰์œผ๋กœ, ๋‚˜๋จธ์ง€๋Š” ๊ฐˆ์ƒ‰์œผ๋กœ ์ฑ„์šฐ๋ ค๊ณ  ํ•œ๋‹ค. ์•„๋ž˜ ๊ทธ๋ฆผ์€ ์ƒ๊ทผ์ด์˜ ๋ฐฉ์˜ ํฌ๊ธฐ๊ฐ€ 4*3์ผ ๋•Œ ์ด๋‹ค. ์–ด๋Š ๋‚  ์ƒ๊ทผ์ด๋„ค ๋ฐฉ์— ํ•˜๊ทผ์ด๊ฐ€ ๋†€๋Ÿฌ์™”๋‹ค. ํ•˜๊ทผ์ด๋Š” ์•„๋ฆ„๋‹ค์šด ํƒ€์ผ ๋ฐฐ์น˜์— ๊ฐ๋™๋ฐ›์•˜๋‹ค. ๋‹ค์‹œ ๋ฐฉ์œผ๋กœ ๋Œ์•„์˜จ ํ•˜๊ทผ์ด๋Š” ๋นจ๊ฐ„์ƒ‰๊ณผ ๊ฐˆ์ƒ‰ ํƒ€์ผ์˜ ๊ฐœ์ˆ˜๋Š” ๊ธฐ์–ตํ–ˆ์ง€๋งŒ, ๋ฐฉ์˜ ํฌ๊ธฐ๋Š” www.acmicpc.net ์ฝ”๋“œ import java.util.Scanner; public class Main { static final int max = 500.. 2020. 1. 19.
[๋ฐฑ์ค€] 10798๋ฒˆ: ์„ธ๋กœ์ฝ๊ธฐ https://www.acmicpc.net/problem/10798 10798๋ฒˆ: ์„ธ๋กœ์ฝ๊ธฐ ์ด ๋‹ค์„ฏ์ค„์˜ ์ž…๋ ฅ์ด ์ฃผ์–ด์ง„๋‹ค. ๊ฐ ์ค„์—๋Š” ์ตœ์†Œ 1๊ฐœ, ์ตœ๋Œ€ 15๊ฐœ์˜ ๊ธ€์ž๋“ค์ด ๋นˆ์นธ ์—†์ด ์—ฐ์†์œผ๋กœ ์ฃผ์–ด์ง„๋‹ค. ์ฃผ์–ด์ง€๋Š” ๊ธ€์ž๋Š” ์˜์–ด ๋Œ€๋ฌธ์ž ‘A’๋ถ€ํ„ฐ ‘Z’, ์˜์–ด ์†Œ๋ฌธ์ž ‘a’๋ถ€ํ„ฐ ‘z’, ์ˆซ์ž ‘0’๋ถ€ํ„ฐ ‘9’ ์ค‘ ํ•˜๋‚˜์ด๋‹ค. ๊ฐ ์ค„์˜ ์‹œ์ž‘๊ณผ ๋งˆ์ง€๋ง‰์— ๋นˆ์นธ์€ ์—†๋‹ค. www.acmicpc.net ์ฝ”๋“œ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); char[][] cWord = new char[5][15]; int max = 0;// ์ž…๋ ฅ๋ฐ›๋Š” .. 2020. 1. 18.
๋ฐ˜์‘ํ˜•