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

関連記事

[Python] multiprocessingを試す (1)

multiprocessing multiprocessing とは、プロセスベースで並列処理を行う python の bulid-in モジュールです。 処理を並列に行えるので、処理が速くなります。 multiprocessing--- プロセスベースの並列...

記事を読む

[Python] ABC017 C 30点

問題 C - ハイスコア 回答 30点回答を考えます。 AtCoder Beginner Contest 017 解説 from AtCoder Inc. N, M = map(int, input().split()) lrs =...

記事を読む

[データ構造] 連想配列をPythonで実装

Python では、連想配列として辞書型が組み込まれているので、そちらを通常は利用します。 5.5.辞書型 (dictionary) マッピング型 ---dict ここでは辞書は使わず、自分の理解のため簡単な連想配列をスクラッチから実装して...

記事を読む

condaコマンド

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

記事を読む

[グラフ] ダイクストラ法

最短経路問題 グラフ理論における最短経路問題(さいたんけいろもんだい、英:shortest path problem)とは、重み付きグラフの与えられた2つのノード間を結ぶ経路の中で、重みが最小の経路を求める最適化問題である。 出典: フリー百科事典『...

記事を読む


Public Domain YottaGin No Rights Reserved.