๋ฐ˜์‘ํ˜•

๐Ÿ“‚ Programming 6

[Python] datetime ๋ชจ๋“ˆ ์ •๋ฆฌ

import datetime now = datetime.datetime.now() one_day = datetime.timedelta(days=1) one_hour = datetime.timedelta(hours=1) # ํ˜„์žฌ ๋‚ ์งœ์™€ ์‹œ๊ฐ„ ์ถœ๋ ฅ # 2023-04-21 01:21:35.277992 print(f'now : {now}') # ํ˜„์žฌ ์—ฐ๋„์™€ ๋‚ ์งœ๋งŒ ์ถœ๋ ฅ # 2023-04-21 print(f'now.date() : {now.date()}') # ํ˜„์žฌ ์‹œ๊ฐ„๋งŒ ์ถœ๋ ฅ # 01:21:35.277992 print(f'now.time() : {now.time()}') # ํ˜„์žฌ ์—ฐ๋„๋งŒ ์ถœ๋ ฅ # 2023 print(f'now.year : {now.year}&#3..

[C++/STL] map ์ •๋ฆฌ

map์€ ํŠน์ • ์ˆœ์„œ์— ๋”ฐ๋ผ 'key-value'๋กœ ๋งคํ•‘๋œ ๊ฐ’์˜ ์กฐํ•ฉ์„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. map ํ—ค๋” #include map ์„ ์–ธ map์€ ๊ธฐ๋ณธ์ ์œผ๋กœ key๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ์ด๋œ๋‹ค. map MP; map ๋‚ด๋ฆผ์ฐจ์ˆœ ์„ ์–ธ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ ์–ธํ•˜๋ฉด๋œ๋‹ค. grater ์ถ”๊ฐ€ map MP; map insert ์š”์†Œ ์‚ฝ์ž… MP["AAA"] = 4; // ("AAA", 4) ์‚ฝ์ž… MP["BBB"] = 8; // ("BBB", 8) ์‚ฝ์ž… MP.insert(make_pair("111", 9)); // ("111", 9) ์‚ฝ์ž… MP.insert(make_pair("0", 100)); // ("0", 100) ์‚ฝ์ž… map value ์ ‘๊ทผ // value ์ ‘๊ทผ cout

[Python] collections Counter ์‚ฌ์šฉ๋ฒ•

collections.Counter dict์˜ ์„œ๋ธŒ ํด๋ž˜์Šค๋กœ ์š”์†Œ๊ฐ€ ํ‚ค๊ฐ€ ๋˜๊ณ  ๊ฐœ์ˆ˜๊ฐ€ ๊ฐ’์ด ๋˜์–ด ํŽธ๋ฆฌํ•˜๊ฒŒ ๊ฐœ์ˆ˜๋ฅผ ์…€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ์ œ 1 import collections S = "aaabbccdd" S_counter = collections.Counter(S) print(S_counter) for a, b in S_counter.items(): print(a, b) ''' ์‹คํ–‰ ๊ฒฐ๊ณผ Counter({'a': 3, 'b': 2, 'c': 2, 'd': 2}) a 3 b 2 c 2 d 2 ''' ์˜ˆ์ œ 2 import collections L = ["zz", "zz", "zz", "aa", "ab", "ab..

[๋ฐฑ์ค€] 1726 ๋กœ๋ด‡ ๋ฐ˜๋ก€

https://www.acmicpc.net/problem/1726 1726๋ฒˆ: ๋กœ๋ด‡ ๋งŽ์€ ๊ณต์žฅ์—์„œ ๋กœ๋ด‡์ด ์ด์šฉ๋˜๊ณ  ์žˆ๋‹ค. ์šฐ๋ฆฌ ์›”๋“œ ๊ณต์žฅ์˜ ๋กœ๋ด‡์€ ๋ฐ”๋ผ๋ณด๋Š” ๋ฐฉํ–ฅ์œผ๋กœ ๊ถค๋„๋ฅผ ๋”ฐ๋ผ ์›€์ง์ด๋ฉฐ, ์›€์ง์ด๋Š” ๋ฐฉํ–ฅ์€ ๋™, ์„œ, ๋‚จ, ๋ถ ๊ฐ€์šด๋ฐ ํ•˜๋‚˜์ด๋‹ค. ๋กœ๋ด‡์˜ ์ด๋™์„ ์ œ์–ดํ•˜๋Š” ๋ช…๋ น์–ด๋Š” www.acmicpc.net -- INPUT -- 9 12 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 ..

[๋ฐฑ์ค€] 5427 ๋ถˆ ๋ฐ˜๋ก€

https://www.acmicpc.net/problem/5427 5427๋ฒˆ: ๋ถˆ ์ƒ๊ทผ์ด๋Š” ๋นˆ ๊ณต๊ฐ„๊ณผ ๋ฒฝ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ๊ฑด๋ฌผ์— ๊ฐ‡ํ˜€์žˆ๋‹ค. ๊ฑด๋ฌผ์˜ ์ผ๋ถ€์—๋Š” ๋ถˆ์ด ๋‚ฌ๊ณ , ์ƒ๊ทผ์ด๋Š” ์ถœ๊ตฌ๋ฅผ ํ–ฅํ•ด ๋›ฐ๊ณ  ์žˆ๋‹ค. ๋งค ์ดˆ๋งˆ๋‹ค, ๋ถˆ์€ ๋™์„œ๋‚จ๋ถ ๋ฐฉํ–ฅ์œผ๋กœ ์ธ์ ‘ํ•œ ๋นˆ ๊ณต๊ฐ„์œผ๋กœ ํผ์ ธ๋‚˜๊ฐ„๋‹ค. ๋ฒฝ์— www.acmicpc.net -- INPUT -- 1 5 7 ...#* ..##. ##.#. #@... ##.#. ..##. ...#* -- OUTPUT -- IMPOSSIBLE -- INPUT -- 1 7 6 ###.### ###.### #.....# #.....# #..@..# ####### -- OUTPUT -- 5 -- INPUT -- 1 5 5 ..... ..... #*#.. #.@.# ###.. -- OUTPUT -- IMPO..

๋ฐ˜์‘ํ˜•