diff --git "a/Algorithm/Code/Week4/Week4_20215129_\352\271\200\354\232\251\354\210\230.ipynb" "b/Algorithm/Code/Week4/Week4_20215129_\352\271\200\354\232\251\354\210\230.ipynb" new file mode 100644 index 0000000..9e539ae --- /dev/null +++ "b/Algorithm/Code/Week4/Week4_20215129_\352\271\200\354\232\251\354\210\230.ipynb" @@ -0,0 +1,109 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d76ff009-6f7b-4e2e-ab8c-83c1f4d59a25", + "metadata": {}, + "source": [ + "# 문제1" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "736c37d9-e694-4ded-b1d5-b18fb3c6f16f", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + " 14\n", + " 14 26456 2 28 13228 3307 7 23149 8 6614 46298 56 4 92596\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "185192\n" + ] + } + ], + "source": [ + "n = int(input())\n", + "lst = list(map(int, input().split()))\n", + "print(min(lst) * max(lst))" + ] + }, + { + "cell_type": "markdown", + "id": "d75bed57-dca6-40fe-a8bc-9ec8b960b7a6", + "metadata": {}, + "source": [ + "# 문제2" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "780f1250-7934-478b-9d4e-08a1c5e31214", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + " 2\n", + " 10 10\n", + " 20 20\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n", + "1\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "n = int(input())\n", + "res = {}\n", + "\n", + "for i in range(1, n+1):\n", + " w, h = map(int, input().split())\n", + " res[str(i)] = math.sqrt(math.pow(w, 2) + math.pow(h, 2)) / 77\n", + "\n", + "res = sorted(res.items(), key = lambda item: item[1], reverse = True)\n", + "\n", + "for r in res:\n", + " print(r[0])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git "a/Algorithm/Code/Week5/Week5_20215129_\352\271\200\354\232\251\354\210\230.ipynb" "b/Algorithm/Code/Week5/Week5_20215129_\352\271\200\354\232\251\354\210\230.ipynb" new file mode 100644 index 0000000..81e69d3 --- /dev/null +++ "b/Algorithm/Code/Week5/Week5_20215129_\352\271\200\354\232\251\354\210\230.ipynb" @@ -0,0 +1,251 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d76ff009-6f7b-4e2e-ab8c-83c1f4d59a25", + "metadata": {}, + "source": [ + "# 문제1\n", + "- OX퀴즈" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "736c37d9-e694-4ded-b1d5-b18fb3c6f16f", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + " 5\n", + " OOXXOXXOOO\n", + " OOXXOOXXOO\n", + " OXOXOXOXOXOXOX\n", + " OOOOOOOOOO\n", + " OOOOXOOOOXOOOOX\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n", + "9\n", + "7\n", + "55\n", + "30\n" + ] + } + ], + "source": [ + "n = int(input())\n", + "lst = [input() for _ in range(n)]\n", + "score = [0 for _ in range(n)]\n", + "\n", + "for i in range(n):\n", + " cor = 0\n", + " summ = 0\n", + " for m, j in enumerate(lst[i]):\n", + " if j == 'O':\n", + " cor += 1\n", + " summ += cor\n", + " else:\n", + " cor = 0\n", + " print(summ)" + ] + }, + { + "cell_type": "markdown", + "id": "d75bed57-dca6-40fe-a8bc-9ec8b960b7a6", + "metadata": {}, + "source": [ + "# 문제2\n", + "- 피보나치 수 2" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "780f1250-7934-478b-9d4e-08a1c5e31214", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + " 10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "55\n" + ] + } + ], + "source": [ + "n = int(input())\n", + "\n", + "if (n < 2):\n", + " print(n)\n", + "else:\n", + " a = 0\n", + " b = 1\n", + " \n", + " for i in range(1, n):\n", + " tmp = b\n", + " b = a + b\n", + " a = tmp\n", + " print(b)" + ] + }, + { + "cell_type": "markdown", + "id": "a854986c-0986-4a9c-834a-bcdd152fbf6b", + "metadata": {}, + "source": [ + "# 문제3\n", + "- 소수찾기" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "4efff902-0a17-44b9-a3d6-69024e314d3e", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + " 4\n", + " 1 3 5 7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "def check(n):\n", + " if n == 1:\n", + " return False\n", + " elif n == 2:\n", + " return True\n", + " \n", + " if n % 2 == 0:\n", + " return False\n", + " \n", + " m = (int)(math.sqrt(n))\n", + " \n", + " for i in range(3, m+1, 2):\n", + " if n % i == 0:\n", + " return False\n", + " return True\n", + " \n", + "\n", + "n = int(input())\n", + "lst = list(map(int, input().split()))\n", + "\n", + "cnt = 0\n", + "for l in lst:\n", + " if (check(l)):\n", + " cnt += 1\n", + "print(cnt)" + ] + }, + { + "cell_type": "markdown", + "id": "3f69684c-54ae-4061-b8bf-5abe4a493b34", + "metadata": {}, + "source": [ + "# 문제5\n", + "- 잃어버린 괄호" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "c04c1ad8-9f07-48a1-b6df-c7de2a87e5e7", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + " 55-50+40\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-35\n" + ] + } + ], + "source": [ + "inn = input()\n", + "now = \"\"\n", + "res = 0\n", + "re2 = 0\n", + "status = 0\n", + "\n", + "for n, i in enumerate(list(inn)):\n", + " if i == '+':\n", + " if status == 0:\n", + " res += int(now)\n", + " else:\n", + " re2 += int(now)\n", + " now = \"\"\n", + " elif i == '-':\n", + " if status == 0:\n", + " res += int(now)\n", + " else:\n", + " re2 += int(now)\n", + " status = 1\n", + " now = \"\"\n", + " else:\n", + " now += i\n", + " \n", + " if n == len(inn) - 1:\n", + " re2 += int(now)\n", + " if status == 0:\n", + " res += int(now)\n", + " else:\n", + " res -= re2\n", + "print(res)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}