Algorithm/SWEA

Algorithm/SWEA

[SWEA - D2] 1989. ์ดˆ์‹ฌ์ž์˜ ํšŒ๋ฌธ ๊ฒ€์‚ฌ

๋‚˜์˜ ํ’€์ด T = int(input()) # ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ์ฃผ์–ด์ง€๋ฏ€๋กœ, ๊ฐ๊ฐ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. for t in range(1, T + 1): a = input() result = 1 for i in range(0,len(a)//2): if a[i] != a[-i-1]: result = 0 break print("#"+str(t) , result ) ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ๋ฌธ์ž์—ด์˜ ์ฒ˜์Œ๊ณผ ๋งˆ์ง€๋ง‰์„ ๊ฐ๊ฐ ๋น„๊ต ๋ฐ˜๋ณต ์ˆ˜ํ–‰ ํšŸ์ˆ˜๋Š” ๋ฌธ์ž์—ด์˜ ์ค‘์•™๊นŒ์ง€๋งŒ ํ•˜๋ฉด ๋œ๋‹ค. ๋ฌธ์ž์—ด๋กœ ํ’€์ด if a == a[::-1]: result = 1 else: result = 0 ๋ฌธ์ž์—ด ์Šฌ๋ผ์ด์‹ฑ์œผ๋กœ ๋ฌธ์ž์—ด์„ ์—ญ์ˆœ์œผ๋กœ ์ฒ˜๋ฆฌ ํ…Œ์ŠคํŠธ์ผ€์ด์Šค์— ์ž…๋ ฅ๊ฐ’์„ ๊ทธ๋Œ€๋กœ ๋ณต์‚ฌํ•˜์˜€๋”๋‹ˆ ๊ณต๋ฐฑ๊นŒ์ง€ ๊ฐ™์ด ๋“ค์–ด์™€์„œ ์ถœ๋ ฅ๊ฐ’์ด ๊ณ„์† 0 ์ด ๋‚˜์™”๋‹ค. ๋ฌธ์ œ ์ž˜๋ชปํ‘ผ์ค„ ์•Œ๊ณ  ๊ณ„์†..

Algorithm/SWEA

[SWEA - D2] 1284. ์ˆ˜๋„ ์š”๊ธˆ ๊ฒฝ์Ÿ

๋‚˜์˜ ํ’€์ด # A์‚ฌ : P์›/1L # B์‚ฌ : Q์› , ์‚ฌ์šฉ๋Ÿ‰ >= R --> S์›/1L # ์ˆ˜๋„์˜ ์‚ฌ์šฉ๋Ÿ‰ W T = int(input()) # ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ์ฃผ์–ด์ง€๋ฏ€๋กœ, ๊ฐ๊ฐ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. for t in range(1, T + 1): P, Q, R, S, W = map(int,input().split()) A = P*W if W > R : B = Q + (W-R) * S else: B = Q result = min(A,B) print("#"+str(t) , result) ํฐ ์–ด๋ ค์›€ ์—†๋Š” ๋ฌธ์ œ

Algorithm/SWEA

[SWEA - D2] 1288. ์ƒˆ๋กœ์šด ๋ถˆ๋ฉด์ฆ ์น˜๋ฃŒ๋ฒ•

๋‚˜์˜ ํ’€์ด T = int(input()) # ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ์ฃผ์–ด์ง€๋ฏ€๋กœ, ๊ฐ๊ฐ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. for t in range(1, T + 1): n = int(input()) ch = [0]*10 k = 0 while sum(ch) != 10: k += 1 for i in str(k*n): ch[int(i)]=1 print("#"+str(t) , k*n) ch ๋ฐฐ์—ด์„ ๋งŒ๋“ค์–ด์„œ ํ˜„์žฌ ๋ณธ ์ˆซ์ž๋ฅผ ์ฒดํฌํ–ˆ๋‹ค. k ์ƒ์ˆ˜๋ฅผ ๋ฐ˜๋ณต๋ฌธ์— 1์”ฉ ์ฆ๊ฐ€์‹œ์ผœ ์ž…๋ ฅ๊ฐ’์„ 1N , 2N , 3N ,, ์ฆ๊ฐ€ ์ •์ˆ˜ํ˜•์ธ ์ž…๋ ฅ๊ฐ’์„ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๊ฐ์ž๋ฆฌ ๊ฒ€์ฆ ์ฒ˜์Œ์— ์ˆ˜ํ–‰ํ•˜๋Š” ํšŸ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ์ธ์ง€ ์•Œ๊ณ  ์‹œ๊ฐ„์ด ์ข€ ๊ฑธ๋ ธ๋‹ค. ๋‹ค๋ฅธ ์‚ฌ๋žŒ ํ’€์ด s = set() #์ค‘๋ณต์ œ๊ฑฐ ์ง‘ํ•จ ์„ ์–ธ s.add(k) if len(s) == 10: #์ง‘ํ•ฉ s์˜..

Algorithm/SWEA

[SWEA - D2] 1986. ์ง€๊ทธ์žฌ๊ทธ ์ˆซ์ž

1๋ถ€ํ„ฐ N๊นŒ์ง€์˜ ์ˆซ์ž์—์„œ ํ™€์ˆ˜๋Š” ๋”ํ•˜๊ณ  ์ง์ˆ˜๋Š” ๋บ์„ ๋•Œ ์ตœ์ข… ๋ˆ„์ ๋œ ๊ฐ’์„ ๊ตฌํ•ด๋ณด์ž. ๋‚˜์˜ ํ’€์ด T = int(input()) # ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ์ฃผ์–ด์ง€๋ฏ€๋กœ, ๊ฐ๊ฐ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. for t in range(1, T + 1): k = int(input()) if k%2 == 0: result = -k//2 else: result = k//2 + 1 print("#"+str(t) , result) ๋ฐ˜๋ณต๋ฌธ ์จ์„œ ํ•˜๋‚˜์”ฉ ๋ถ€ํ˜ธ ๋ฐ”๊ฟ”๊ฐ€๋ฉด์„œ ๋”ํ• ํ•„์š” ์—†์ด ๊ทธ๋ƒฅ ์ˆ˜ํ•™์ ์ธ ๊ทœ์น™์œผ๋กœ ํ’€์—ˆ๋‹ค.

Algorithm/SWEA

[SWEA - D2] 1945. ๊ฐ„๋‹จํ•œ ์†Œ์ธ์ˆ˜๋ถ„ํ•ด

๋‚˜์˜ ํ’€์ด T = int(input()) # ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ์ฃผ์–ด์ง€๋ฏ€๋กœ, ๊ฐ๊ฐ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. for t in range(1, T + 1): n = int(input()) arr = [2,3,5,7,11] print("#"+str(t) , end=" ") for i in arr: cnt = 0 while n%i ==0: cnt += 1 n = n//i print(cnt , end=" ") print() ๋ฐฐ์—ด๋กœ ๋งŒ๋“ค๊ณ  ๋ฐ˜๋ณตํ•˜๊ฒŒ ๋งŒ๋“ค์—ˆ๋‹ค. ๋ฐฐ์—ด ๋ฐ˜๋ณต ์ˆ˜ํ–‰ํ•  ๋•Œ๋งˆ๋‹ค ์นด์šดํ„ฐ ๋ณ€์ˆ˜๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๊ณ  ๊ฐ’์„ ๊ตฌํ•˜๊ณ  ์ถœ๋ ฅ ๋‹ค๋ฅธํ’€์ด ์ฐพ์•„๋ดค๋Š”๋ฐ ๋ฐฐ์—ด for ๋ฌธ์— while ์กฐ๊ฑด๋„ฃ์–ด์„œ ๊ตฌํ•˜๊ธฐ ๋Œ€๋ถ€๋ถ„ ์ด๋ ‡๊ฒŒ ํ‘ธ๋Š”๋“ฏ?

Algorithm/SWEA

[SWEA] D1 ๋ฌธ์ œํ’€์ด

19๋ฌธ์ œ ํ’€์ด ์™„๋ฃŒ ์˜ค๋žœ๋งŒ์— ๋ฌธ์ œํ‘ธ๋‹ˆ๊นŒ ๋‹ค ๊นŒ๋จน์—ˆ๋„ค; format ํ™œ์šฉ {} ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ์˜ ์ข…๋ฅ˜์— ์ƒ๊ด€์—†์ด print๋ฌธ์œผ๋กœ ํ‘œํ˜„์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. print("์˜ฌํ•ด๋Š” {}๋…„, ๋‚ด๋…„์€ {}๋…„ ์ž…๋‹ˆ๋‹ค.".format(2020, 2021)) print("๋‚˜๋Š” {}์„ ํƒ‘๋‹ˆ๋‹ค.".format('์ง€ํ•˜์ฒ ')) ord( ๋ฌธ์ž ) : ์•„์Šคํ‚ค์ฝ”๋“œ๋กœ ๋Œ€์ƒ์˜ ์ˆซ์ž ๊ฐ’์„ ๋ฆฌํ„ดํ•จ chr( ์ˆซ์ž ) : ์•„์Šคํ‚ค์ฝ”๋“œ์—์„œ ๋Œ€์ƒ์˜ ๋ฌธ์ž ๊ฐ’์„ ๋ฆฌํ„ดํ•จ 2056. ์—ฐ์›”์ผ ๋‹ฌ๋ ฅ ๋‚˜์˜ ํ’€์ด T = int(input()) for t in range(1, T + 1): cal = input() year = (cal[0:4]) mon = cal[4:6] day = cal[6:8] if int(mon) >= 13 or int(mon) == 0 : r..

hello_u
'Algorithm/SWEA' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (4 Page)