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

問題 A - おいしいたこ焼きの作り方 回答 割り算するだけ。 import sys # input処理を高速化する input = sys.stdin.readline def main(): X, Y = list(map(int, inp...

記事を読む

[Python] Pythonの練習問題サイト(英語)

時間がある時にやるための自分用のリスト。 下に行くほど難しい感じかと。 Codingbat projecteuler codeabbey Reddit の Daily Practice Problems 意味...

記事を読む

[Python] 二分探索木/ Binary Search Tree

2分探索木をPythonで実装します。 二分探索木 二分探索木(にぶんたんさくぎ、英:binary search tree)は、コンピュータプログラムにおいて、「左の子孫の値 ≤ 親の値 ≤ 右の子孫の値」という制約を持つ二分木である。探索木のうちで最も基本的な木...

記事を読む

[Python] multiprocessingを試す (4)

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

記事を読む

[Python] WordCloudを使ってみる

こちらのほぼ写経です。 Pythonのwordcloudというモジュールを使ってWordCloudを作ってみます。 word cloud / tag cloud タグ・クラウド(tag cloud) はタグの視覚的記述を指す。 出典: フリー百科事典『ウ...

記事を読む


Public Domain YottaGin No Rights Reserved.