๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ35

[SWEA] 1933. ๊ฐ„๋‹จํ•œ N์˜ ์•ฝ์ˆ˜ 1933. ๊ฐ„๋‹จํ•œ N์˜ ์•ฝ์ˆ˜ - D1 ์•ฝ์ˆ˜์˜ ๊ฐœ๋…์„ ์ด์šฉํ•œ๋‹ค. ์•ฝ์ˆ˜๋Š” N์„ ์–ด๋–ค ์ˆ˜๋กœ ๋‚˜๋ˆด์„ ๋•Œ ๋‚˜๋จธ์ง€๊ฐ€ 0์ธ ๊ฒƒ์ด๋‹ค. import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for(int i = 1; i 2022. 5. 19.
[SWEA] 1938. ์•„์ฃผ ๊ฐ„๋‹จํ•œ ๊ณ„์‚ฐ๊ธฐ 1938. ์•„์ฃผ ๊ฐ„๋‹จํ•œ ๊ณ„์‚ฐ๊ธฐ - D1 ๋‘ ์ˆซ์ž๋ฅผ ๋ฐ›์•„ ์‚ฌ์น™์—ฐ์‚ฐ(+, -, *, /)์„ ์ˆœ์„œ๋Œ€๋กœ ํ•˜๊ณ  ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค. num1, num2๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ  +, -, *, / ์ˆœ์„œ๋Œ€๋กœ ์—ฐ์‚ฐํ•œ ๊ฐ’์„ ์ถœ๋ ฅํ•˜๋„๋ก ํ–ˆ๋‹ค. import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int num1 = sc.nextInt(); int num2 = sc.nextInt(); System.out.println(num1+num2); System.out.println(num1-num2).. 2022. 5. 18.
[SWEA] 2025. N์ค„ ๋ง์…ˆ 2025. N์ค„ ๋ง์…ˆ - D1 ์ฃผ์–ด์ง„ ์ˆซ์ž N๊นŒ์ง€ 1๋ถ€ํ„ฐ ๋”ํ•œ ๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค. 1๋ถ€ํ„ฐ N๊นŒ์ง€ ๋”ํ•œ ํ•ฉ์€ N(N+1)/2 ๋ผ๋Š” ๊ณต์‹์„ ์ด์šฉํ•œ๋‹ค. (์ค‘ํ•™๊ต ๋•Œ ๋ฐฐ์› ๋˜ ๊ณต์‹์ธ ๊ฒƒ ๊ฐ™๋‹ค..?) import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); System.out.println(N*(N+1)/2); } } ๋ ๐Ÿง 2022. 5. 18.
[SWEA] 2027. ๋Œ€๊ฐ์„  ์ถœ๋ ฅํ•˜๊ธฐ 2027. ๋Œ€๊ฐ์„  ์ถœ๋ ฅํ•˜๊ธฐ - D1 ๊ทธ๋ƒฅ ์ถœ๋ ฅํ•˜๋ ค๋‹ค๊ฐ€ ๋ฐ˜๋ณต๋ฌธ ์—ฐ์Šตํ•˜๋ผ๋Š” ๊ฑด๊ฐ€ ์‹ถ์–ด์„œ ๋ฐ˜๋ณต๋ฌธ์„ ์ด์šฉํ–ˆ๋‹ค. i์™€ j๊ฐ€ ๊ฐ™์œผ๋ฉด #์„ ์ถœ๋ ฅํ•˜๊ณ  ์•„๋‹ ๊ฒฝ์šฐ +๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. (ํ•™๊ต ๋‹ค๋‹ ๋•Œ ๋ณ„์ฐ๊ธฐ ์—ฐ์Šตํ•˜๋˜๊ฑฐ ์ƒ๊ฐ๋‚œใ„ทใ…..) import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { for(int i = 0; i < 5; i++) { for(int j = 0; j < 5; j++){ if(i==j) System.out.print("#"); else System.out.print("+"); } System.out.println(); } } }.. 2022. 5. 18.
[SWEA] 2043. ์„œ๋ž์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ 2043. ์„œ๋ž์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ - D1 K ์ˆ˜๋ถ€ํ„ฐ 1์”ฉ ์ฆ๊ฐ€ํ•ด๋ณด๋ฉฐ password๋ฅผ ๋งž์ถ”๋Š” ๋ฌธ์ œ์ด๋‹ค. ๋”ฐ๋ผ์„œ ์ž…๋ ฅ๋ฐ›์€ password์—์„œ K๋งŒํผ ๋นผ์ฃผ๊ณ  1์„ ๋”ํ•œ๋‹ค. import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int password =sc.nextInt(); int K = sc.nextInt(); System.out.println(password - K + 1); } } ๋ ๐Ÿง 2022. 5. 18.
[SWEA] 2046. ์Šคํƒฌํ”„ ์ฐ๊ธฐ 2046. ์Šคํƒฌํ”„ ์ฐ๊ธฐ - D1 ์ž…๋ ฅ๋ฐ›์€ ์ˆ˜๋งŒํผ for๋ฌธ์„ ๋Œ๋ ค #์„ ์ถœ๋ ฅํ•ด์ค€๋‹ค. System.out.println() ์œผ๋กœ ํ•˜๋ฉด ์ค„๋ฐ”๊ฟˆ ๋˜๋‹ˆ๊นŒ System.out.print() ์ด์šฉํ•˜๊ธฐ import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for(int test_case = 1; test_case 2022. 5. 18.
[SWEA] 2047. ์‹ ๋ฌธ ํ—ค๋“œ๋ผ์ธ 2047. ์‹ ๋ฌธ ํ—ค๋“œ๋ผ์ธ - D1 ์•„์Šคํ‚ค์ฝ”๋“œ๋ฅผ ์ด์šฉํ•ด์„œ ์†Œ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ๋ฐ”๊ฟ”์ค„ ์ˆ˜ ์žˆ๋Š” if๋ฌธ์„ ์ด์šฉํ–ˆ๋‹ค. ์†Œ๋ฌธ์ž a๊ฐ€ 97์ด๋ผ 97๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™์„ ๊ฒฝ์šฐ a์™€ A - ์•ŒํŒŒ๋ฒณ ๋Œ€์†Œ๋ฌธ์ž ์ฐจ์ด๋งŒํผ ๋นผ์คฌ๋‹ค. ํ•˜์ง€๋งŒ ์ž๋ฐ”๋Š”.. ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฐ”๋กœ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํ•จ์ˆ˜๋ฅผ ์ œ๊ณต ์ค‘์ด๋ผ ๊ทธ๊ฑธ๋กœ๋„ ํ’€์–ด๋ณด์•˜๋‹ค.. import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); String sentense = sc.next(); for(int i = 0; i < sentense.length.. 2022. 5. 17.
[SWEA] 2050. ์•ŒํŒŒ๋ฒณ์„ ์ˆซ์ž๋กœ ๋ณ€ํ™˜ [SWEA] 2050. ์•ŒํŒŒ๋ฒณ์„ ์ˆซ์ž๋กœ ๋ณ€ํ™˜ - D1 1. String์œผ๋กœ ๋ฌธ์ž์—ด์„ ๋ฐ›๋Š”๋‹ค. 2. CharAt๋ฅผ ์ด์šฉํ•ด ๋ถ„๋ฆฌํ•œ๋‹ค 3. ์•„์Šคํ‚ค ์ฝ”๋“œ์—์„œ ๋ฌธ์ž 'A' ๊ฐ€ ์ˆซ์ž 65์ด๋ฏ€๋กœ, ๊ฐ’์—๋‹ค 'A'+1์„ ํ•ด์ค€๋‹ค. (CharAt() : String์œผ๋กœ ์ €์žฅ๋œ ๋ฌธ์ž์—ด ์ค‘์—์„œ ํ•œ ๊ธ€์ž๋งŒ ์„ ํƒํ•ด์„œ charํƒ€์ž…์œผ๋กœ ๋ณ€ํ™˜) - toCharArray๋ฅผ ์ด์šฉํ•ด์„œ ๋ถ„๋ฆฌํ•ด๋„ ๊ฐ€๋Šฅํ•˜๋‹ค. import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); String s = sc.next();.. 2022. 5. 17.
[SWEA] 2056. ์—ฐ์›”์ผ ๋‹ฌ๋ ฅ 2056.์—ฐ์›”์ผ ๋‹ฌ๋ ฅ - D1 1. 1์›”๋ถ€ํ„ฐ 12์›”๊นŒ์ง€ 1์ผ๋ถ€ํ„ฐ ๋ฉฐ์น ๊นŒ์ง€ ์ธ์ง€ days ๋ฐฐ์—ด์— ์ €์žฅํ•ด๋‘”๋‹ค. 2. ๋‚ ์งœ๋ฅผ String์œผ๋กœ ์ž…๋ ฅ๋ฐ›๊ณ  String์˜ substring์„ ์ด์šฉํ•ด month ๋ถ€๋ถ„๊ณผ day ๋ถ€๋ถ„์„ ๋ถ„๋ฆฌํ•œ๋‹ค. 3. month๊ฐ€ 1~12์‚ฌ์ด์ธ์ง€, day๊ฐ€ 1~๋งˆ์ง€๋ง‰ ๋‚ ์งœ(30,31,28)์— ๋งž๊ฒŒ ๋˜์–ด์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค 4. ์ถœ๋ ฅํ˜•์‹๋Œ€๋กœ ์ €์žฅํ•˜๊ณ  ์ถœ๋ ฅํ•œ๋‹ค. import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int T=sc.nextInt(); .. 2022. 5. 7.
[SWEA] 2058. ์ž๋ฆฟ์ˆ˜ ๋”ํ•˜๊ธฐ 2058. ์ž๋ฆฟ์ˆ˜ ๋”ํ•˜๊ธฐ - D1 ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ  ์›๋ž˜ ์ˆซ์ž์—์„œ sum์— 10์œผ๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ๋”ํ•˜๊ณ  ๊ทธ ์ˆ˜๋ฅผ 10์œผ๋กœ ๋‚˜๋ˆ„๋Š” ๊ฒƒ์„ ๋ฐ˜๋ณตํ•˜๋ฉฐ ์ž๋ฆฟ์ˆ˜๋ฅผ ๋”ํ•  ์ˆ˜ ์žˆ๋‹ค. n = ์›๋ž˜ ์ˆ˜ ๋ผ๊ณ  ํ•˜๋ฉด, 1. ( n % 10) ์—ฐ์‚ฐ์œผ๋กœ ๋งจ ์˜ค๋ฅธ์ชฝ ์ˆ˜๋ฅผ (์ผ์˜ ์ž๋ฆฌ์ˆ˜) ์ถ”์ถœํ•  ์ˆ˜ ์žˆ๋‹ค. 2. ์ถ”์ถœํ•œ ๊ฐ’์„ sum ์— ๋”ํ•œ๋‹ค. 3. (n / 10) ์—ฐ์‚ฐ์œผ๋กœ ์ž๋ฆฌ์ˆ˜๋ฅผ ์ค„์ธ๋‹ค. 4. n์ด 0์ด ๋˜๊ธฐ ์ „๊นŒ์ง€ ์ด ๊ณผ์ •์„ ๋ฐ˜๋ณตํ•œ๋‹ค. import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in.. 2022. 5. 7.