From 09883109b9d06bd467967a36292660090a988f32 Mon Sep 17 00:00:00 2001 From: pu2rile <3o920@naver.com> Date: Thu, 11 Jul 2024 22:13:22 +0900 Subject: [PATCH 1/5] 2024-07-11 --- pu2rile/README.md | 4 +++- ...24\355\225\231\354\213\235\353\237\211.py" | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 "pu2rile/\354\212\244\355\203\235/\355\231\224\355\225\231\354\213\235\353\237\211.py" diff --git a/pu2rile/README.md b/pu2rile/README.md index 70f15e8..2376f74 100644 --- a/pu2rile/README.md +++ b/pu2rile/README.md @@ -9,4 +9,6 @@ | 5차시 | 2024.04.10 | 그리디 알고리즘 | [국회의원 선거](https://www.acmicpc.net/problem/1417) | [#18](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/18#issue-2235862658) | 6차시 | 2024.05.10 | 그리디 알고리즘 | [ATM](https://www.acmicpc.net/problem/11399) | [#25](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/25#issue-2289086909) | 7차시 | 2024.05.10 | 완전 탐색 알고리즘 | [영화감독 숌](https://www.acmicpc.net/problem/1436) | [#26](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/25#issue-2289086909) -| 8차시 | 2024.05.14 | 그리디 알고리즘 | [팔](https://www.acmicpc.net/problem/1105) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/28#issue-2295901384) \ No newline at end of file +| 8차시 | 2024.05.14 | 그리디 알고리즘 | [팔](https://www.acmicpc.net/problem/1105) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/28#issue-2295901384) +| 9차시 | 2024.05.27 | 구현 | [오늘도 졌다](https://www.acmicpc.net/problem/14582) | [#29](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/29#issue-2320060288) +| 10차시 | 2024.07.11 | 스택 | [화학식량](https://www.acmicpc.net/problem/2257) | [#34]() \ No newline at end of file diff --git "a/pu2rile/\354\212\244\355\203\235/\355\231\224\355\225\231\354\213\235\353\237\211.py" "b/pu2rile/\354\212\244\355\203\235/\355\231\224\355\225\231\354\213\235\353\237\211.py" new file mode 100644 index 0000000..e964f10 --- /dev/null +++ "b/pu2rile/\354\212\244\355\203\235/\355\231\224\355\225\231\354\213\235\353\237\211.py" @@ -0,0 +1,22 @@ +chemical = input() +stack = [] +atomic = {'H':1, 'C':12, 'O':16} # 원자량 딕셔너리 + +for c in chemical: + if c =='(': + stack.append(c) + elif c == 'H' or c == 'C' or c == 'O': + stack.append(atomic[c]) # 입력받은 원자의 원자량을 스택에 추가 + elif c == ')': + temp = 0 # 닫는 괄호를 만나면 temp 초기화 + while True: + if stack[-1] == '(': # 스택의 top이 여는 괄호면 + stack.pop() # 스택에서 여는 괄호를 삭제 + stack.append(temp) # 스택에 temp 추가 + break + else: + temp += stack.pop() # 여는 괄호 전까지의 스택 안의 모든 값을 temp에 저장 + else: # c가 숫자라면 + stack.append(stack.pop()*int(c)) # 스택의 top 값과 숫자를 곱하여 스택에 추가 + +print(sum(stack)) \ No newline at end of file From 0f23fbcc45b4dc710634796e443dfff7b647b892 Mon Sep 17 00:00:00 2001 From: pu2rile <3o920@naver.com> Date: Thu, 11 Jul 2024 22:14:24 +0900 Subject: [PATCH 2/5] Create .DS_Store --- pu2rile/.DS_Store | Bin 0 -> 8196 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pu2rile/.DS_Store diff --git a/pu2rile/.DS_Store b/pu2rile/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b798810e983d08b0ccc32dc28c0dd09244402a07 GIT binary patch literal 8196 zcmeI1&ubGw6vy8rtKC=%5h~;&40sJSO+#(*vc~jK&`VeJU?pbVpo`nxk{{*}0(;hr z$DTZSOzjm-M0Y%Qf}Mx z0675Au`ta}V>QCqI4cQD$s^}c3C085gcX>B4X{_;gtt1N2q*%IfFhs>C<6Zj0eogN z)5kpb#i*(k0Y%_c5@7oS#lqB(8VKcE2Ua`)hu-rWZYnZoRgGxAm z_a9iUZ{aB3P~<1-+%InY6sduGpsl)LAB-R2V|ALF@;uwtrt36Yg~9r}Qa( zTEAyL@;hd$)@nD)wZ>i6yXE_?b=0m|x1D;Ynw`Dwd##$|)f+s(vFqrve#h}_zf<Ys9BOr2P zff><1uAgCx&-aPh@Lb<}h<)a(4-R+wZ)Sn+-sped>F;mFc)UWNFtddJgs@4>E6(Zl z*FD_Lzi8X*gTuF5?`NW%$i+CPxc|v>!gW);QetapxmftqHKfPq72}kCxAgh>?vE&) z6kBcKRh0Vpa`-LkL)Z#U_?$eozjNoY`Nl|{`&8M}fDVTr_Q&3RY&Uul+ObB)ObDZq zbBi%U9Lf}d2!XWd Date: Thu, 11 Jul 2024 22:20:37 +0900 Subject: [PATCH 3/5] Update README.md --- pu2rile/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pu2rile/README.md b/pu2rile/README.md index 2376f74..7d06827 100644 --- a/pu2rile/README.md +++ b/pu2rile/README.md @@ -11,4 +11,4 @@ | 7차시 | 2024.05.10 | 완전 탐색 알고리즘 | [영화감독 숌](https://www.acmicpc.net/problem/1436) | [#26](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/25#issue-2289086909) | 8차시 | 2024.05.14 | 그리디 알고리즘 | [팔](https://www.acmicpc.net/problem/1105) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/28#issue-2295901384) | 9차시 | 2024.05.27 | 구현 | [오늘도 졌다](https://www.acmicpc.net/problem/14582) | [#29](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/29#issue-2320060288) -| 10차시 | 2024.07.11 | 스택 | [화학식량](https://www.acmicpc.net/problem/2257) | [#34]() \ No newline at end of file +| 10차시 | 2024.07.11 | 스택 | [화학식량](https://www.acmicpc.net/problem/2257) | [#35](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/35#issue-2403173169) \ No newline at end of file From 27627250206fb874a8576f3a35a1b758358c5260 Mon Sep 17 00:00:00 2001 From: pu2rile <3o920@naver.com> Date: Thu, 11 Jul 2024 22:20:42 +0900 Subject: [PATCH 4/5] Create .DS_Store --- .DS_Store | Bin 0 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..097f6a03febd3f58dc58c3727435e2fed0922d49 GIT binary patch literal 6148 zcmeHKL2uJA6n^f?nrH&`0Maf!?ODNre1D6HC0Z>Uuw1s7H)ihM7s+2SQ z7_R&h{tGAgp6#JE1&#pJO{FA~CAdeWE@QIdH~~i{cl?{p=goF_9in zsB4^3P3II-Nv9jxHt;Vhz+-od&Pb{;yE=Y89a2CCPYU@qDP)2?en}p|_r5Dbjc6Op zj4H5ede_SR+{*3I6j=eyD5rw5^=xtX&)LbMnwtOdC7Bj^HTV6mqO;Y#vE6fe&W`gs zI+KfN9?$D)6wh9A>zR~Aa#@d)=Xti6^lv|w Date: Thu, 11 Jul 2024 22:20:48 +0900 Subject: [PATCH 5/5] Create .DS_Store --- "pu2rile/\354\212\244\355\203\235/.DS_Store" | Bin 0 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "pu2rile/\354\212\244\355\203\235/.DS_Store" diff --git "a/pu2rile/\354\212\244\355\203\235/.DS_Store" "b/pu2rile/\354\212\244\355\203\235/.DS_Store" new file mode 100644 index 0000000000000000000000000000000000000000..efd16c225fed92eff2ee313f143f4c147eec7ae1 GIT binary patch literal 6148 zcmeHKF-`+P474GUf{;*_ih^Qa5Q!fgQ7EWsDIlSWB84Ue-F1A0j+TN4@GF?H4a#w$ zr2t#9XV*Kvy_@2^DMXOyRMP&SCevgomQCs=z_ zj>{5$yIo&iWg_?TaJgD9=BxD_Jig>JeDZFFk;w4v^yPXd^ZXmr=owOhR3H^d1yX^3 zuK;>BZFK0EF%?J!Qh_f8_vc;<$gVzMMj#iGml>_r2KwZ*O If!|Qz1I1h^?f?J) literal 0 HcmV?d00001