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] ABC013 A

問題 A - A 回答  ord で Unicode コードポイント に変換して引き算します。 X = input() ans = ord(X) - ord('A') + 1 print(ans) 辞書で対応表を作成します。 X = inp...

記事を読む

[Python] ABC019 D

問題 D - 高橋くんと木の直径 回答 20点回答 全て探索します。 AtCoder Beginner Contest 019 解説 from AtCoder Inc. import sys N = int(input())...

記事を読む

[Python] pnadasの基本的な使いかた

pandas の基本的な使い方、備忘録です。 公式 pandas: powerful Python data analysis toolkit jupyter notebook を使っている時は、メソッドにカーソルを置いて、Shift + Tab でそのメソッ...

記事を読む

[Python] ABC009 A

問題 A - 引越し作業 切り上げ処理 math.ceil(x) 商と余りを一度に取得 divmod(a, b) 回答 N = int(input()) nums_thereback = N // 2 + N % 2 print...

記事を読む

[Python] multiprocessingを試す (4)

前回からの続きです。 pool python で mulitprocessing を行う方法として、process 以外に pool があります。 プロセスプール process と pool の違い Python Multiproce...

記事を読む


Public Domain YottaGin No Rights Reserved.