YottaGin

Freedom is a responsible choice.

[Python] ABC004 C

2019/3/26 2019/4/17 プログラミング

C – 入れ替え

n = int(input())

n = n % 30

lst_num = ['1', '2', '3', '4', '5', '6']

for i in range(n):
    first = i % 5 + 1
    second = i % 5 +2
    lst_num[first-1], lst_num[second-1] = lst_num[second-1], lst_num[first-1]

print(int(''.join(lst_num)))

メモ

  • pythonで変数のswap(入れ替え)について考えて検討してみた

Atcoder, Python GinO

関連記事

condaコマンド

windows、Anaconda Command Prompt上でanacondaを使う際のcondaコマンドについて、備忘録的にまとめます。 公式コマンドレファレンス Command reference ライブラリ一覧 インストールしたライブラリ一覧を...

記事を読む

[Python] Educational DP Contest L – Deque

問題 L - Deque 参考 例題 3.EDPC L 問題 - Deque 〜 得点差も最大化したい 〜 Deque 回答 DP PyPyではAC。 import sys # input処理を高速化する input = sys...

記事を読む

[Python] k近傍法 (1)

scikit-learn という有名なモジュールを用いて、有名なあやめの分類問題を、k近傍法で解いてみます。 IPython で行います。 k近傍法 k近傍法(ケイきんぼうほう、英:k-nearest neighbor algorithm,k-NN)は、特徴空...

記事を読む

[Python] requests/beautifulsoup でスクレイピング

requests/beautifulsoup/lxml のコンビでスクレイピングを行ってみます。 Requests Requests: HTTP for Humans™ Python で一番使いやすいHTMLライブライです。 下記コマンドで...

記事を読む

[Python] プリム法

プリム法を用いて、重み付き無向グラフの最小全域木を求めます。 プリム法はダイクストラ法とほぼ同じで、コードもダイクストラ法のものをほぼ流用しています。 全域木 全域木とは、グラフの中の全ての頂点を使って作られる木のことです。 全域木(ぜ...

記事を読む


Public Domain YottaGin No Rights Reserved.