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

関連記事

多クラス分類の GridSearchCV で multiclass_log_loss を使う

lightgbm の多クラス分類のパラメータチューニングで GridSearchCV を使うときに、multiclass_log_loss を scoring として使う方法です。 ググってもなかなか見つからなかったので、今後のためにメモしておきます。 Custom...

記事を読む

[Python] DFSによるグラフの探索

無向グラフをDFSで探索するアルゴリズムを Python で記述します。 グラフは隣接リストを用いて表現します。 深さ優先探索 深さ優先探索(ふかさゆうせんたんさく、英: depth-first search, DFS、バックトラック法ともいう)...

記事を読む

[Python] ABC018 A

問題 A - 豆まき 回答 A = int(input()) B = int(input()) C = int(input()) l = l_sorted = sorted(l) for num in l: print(l_sorted.in...

記事を読む

[Python] ABC001 A

A - 積雪深差 h1 = int(input()) h2 = int(input()) print(h1-h2) さすがに解ける。 int(input()) input()はstirngを返すのでint()でintに変換する。

記事を読む

[Python] pandasでUnicodeDecodeErrorが起きた時

Windowsで作成したcsvファイルをpandasで開こうとすると、良くUnicodeDecodeErrorが出ていらいらさせられます。 read_csvでencoding='cp932'つけることで今までは解決していたのですが、なぜか今回はうまくいきません。 ...

記事を読む


Public Domain YottaGin No Rights Reserved.