Algorithm
Youngsung Choi Youngsung Choi { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### 2022.01.31자 알고리즘 풀이" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "T = int(input())\n", "for i in range(T):\n", " num1, num2 = input().split()\n", " print(\"Case #{}: {} + {} = {}\".format(i+1,num1, num2, int(num1) + int(num2)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2438 별 찍기 -1" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 5\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "*\n", "**\n", "***\n", "****\n", "*****\n" ] } ], "source": [ "T = int(input())\n", "for i in range(1,T+1):\n", " for j in range(i):\n", " print('*',end=\"\")\n", " print()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2439 별 찍기 - 2" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 5\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " *\n", " **\n", " ***\n", " ****\n", "*****\n" ] } ], "source": [ "T = int(input())\n", "for i in range(1,T+1):\n", " for y in range(T-i):\n", " print(' ',end=\"\")\n", " for j in range(i):\n", " print('*',end=\"\")\n", " print()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 10871 X보다 작은 수" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 10 5\n", " 1 10 4 9 2 3 8 5 7 6\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1 4 2 3 " ] } ], "source": [ "N, X = input().split()\n", "A = list(map(int, input().split()))\n", "\n", "for num in A:\n", " if num < int(X):\n", " print(num, end=\" \")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 10952 A+B - 5" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 1 1\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2\n" ] }, { "name": "stdin", "output_type": "stream", "text": [ " 2 3\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "5\n" ] }, { "name": "stdin", "output_type": "stream", "text": [ " 9 8\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "17\n" ] }, { "name": "stdin", "output_type": "stream", "text": [ " 5 2\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "7\n" ] }, { "name": "stdin", "output_type": "stream", "text": [ " 0 0\n" ] } ], "source": [ "while True:\n", " x, y = input().split()\n", " if x == '0' and y == '0':\n", " break\n", " print(int(x)+int(y))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 10951\tA+B - 4" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " \n" ] } ], "source": [ "while True:\n", " try:\n", " x, y = map(int, input().split())\n", " print(x+y)\n", " except:\n", " break" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1110\t더하기 사이클" ] }, { "cell_type": "code", "execution_count": 84, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 71\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "18\n", "89\n", "97\n", "76\n", "63\n", "39\n", "92\n", "21\n", "13\n", "34\n", "47\n", "71\n", "12\n" ] } ], "source": [ "def getNumber(num):\n", " return int(num % 10)\n", "\n", "cnt = 0\n", "N = int(input())\n", "temp = N\n", "\n", "while True:\n", " temp = getNumber(temp) * 10 + getNumber(temp / 10 + getNumber(temp))\n", " cnt = cnt + 1\n", " if(N == temp):\n", " break\n", "print(cnt)" ] } ], "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 }