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

関連記事

リエントラント

問題 応用情報技術者平成24年秋期 午前問8 リアルタイムシステムにおいて,複数のタスクから並行して呼び出された場合に,同時に実行する必要がある共用ライブラリのプログラムに要求される性質はどれか。 リエントラントリカーシブリユーザブルリロケータブル 答...

記事を読む

[Python] ABC004

B - 回転 table = [] while True: try: table.append(list(input().split())) except: break table = table #print(table) table_180...

記事を読む

[Python] クラスメソッドと静的メソッド

今まで、Python でのクラスメソッド、静的メソッドを意識したことがなかったので、備忘録です。 Difference between staticmethod and classmethod 静的メソッドはクラスの外に定義されている関数と同じ。確たる理由がなければ...

記事を読む

[Python] k近傍法での株価予測

ロジスティック回帰で、翌日の株価の上昇/下降を予測します。 k近傍法 k近傍法(ケイきんぼうほう、英: k-nearest neighbor algorithm, k-NN)は、特徴空間における最も近い訓練例に基づいた分類の手法であり、パターン認識でよく使われる...

記事を読む

[Python] ABC008 B

問題 B - 投票 回答 名前を辞書で管理し、ソートします。 N = int(input()) dict_names = dict() for _ in range(N): name = input() if name not in d...

記事を読む


Public Domain YottaGin No Rights Reserved.