Algorithm5

0:\n", " des -= 1\n", " if num == 1 :\n", " num = ori\n", " ori += 1\n", " isRight = not isRight\n", " else:\n", " num -= 1\n", "if isRight:\n", " print('{}/{}'.format(num, ori - num))\n", "else:\n", " print('{}/{}'.format(ori - num, num))" ] }, { "cell_type": "code", "execution_count": 79, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ " 15\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1/5\n" ] } ], "source": [ "des = int(input())\n", "line = 1\n", "\n", "while des > line:\n", " des -= line\n", " line += 1\n", "\n", "if line % 2 == 0:\n", " a = des\n", " b = line - des + 1\n", "else:\n", " a = line - des + 1\n", " b = des\n", " \n", "print(a, \"/\", b, sep=\"\")" ] } ], "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 }