Algorithm2
Youngsung Choi Youngsung Choi { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 2022.02.01 알고리즘" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1차원 배열" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 10818\t최소, 최대" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 5\n", " 20 10 35 30 7\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "7 35\n" ] } ], "source": [ "N = map(int, input())\n", "numbers = list(map(int, input().split()))\n", "print(min(numbers), max(numbers))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2562\t최댓값" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 3\n", " 29\n", " 38\n", " 12\n", " 57\n", " 74\n", " 40\n", " 85\n", " 61\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "85\n", "8\n" ] } ], "source": [ "result = [0, 0]\n", "\n", "for i in range(9):\n", " x = int(input())\n", " if result[0] < x:\n", " result = x, i+1\n", "for i in result:\n", " print(i)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2577\t숫자의 개수" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import collections\n", "\n", "num = 1\n", "for i in range(3):\n", " num = num * int(input())\n", "num = collections.Counter(str(num))\n", "for i in range(10):\n", " temp = num.get(str(i))\n", " if(temp == None): print(0)\n", " else: print(temp)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3052\t나머지" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 1\n", " 2\n", " 3\n", " 4\n", " 5\n", " 6\n", " 7\n", " 8\n", " 9\n", " 10\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "10\n" ] } ], "source": [ "result = []\n", "for i in range(10):\n", " result.append(int(input()) % 42)\n", "print(len(set(result)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1546\t평균" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "T = int(input())\n", "score_list = list(map(int, input().split()))\n", "result = 0\n", "max_score = max(score_list)\n", "for i in score_list:\n", " result = result + i / max_score * 100\n", "print(result / len(score_list))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 8958\tOX퀴즈" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 1\n", " OOOOOOOOOO\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "55\n" ] } ], "source": [ "def counter(score):\n", " result = 0\n", " cnt = 0\n", " for i in score:\n", " if(i == 'O'):\n", " cnt = cnt + 1\n", " result = result + cnt\n", " else:\n", " cnt = 0\n", " return result\n", "\n", "case = int(input())\n", "for i in range(case):\n", " print(counter(input()))" ] } ], "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.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }