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で実装

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

記事を読む

[Python] 最長増加部分列(LIS)問題

ほぼ以下の内容です。 GeeksForGeeks Python program for Longest Incresing Subsequence 最長増加部分列(LIS: Longest Increasing Subsequence)問題 ...

記事を読む

[Python] 2分探索

2分探索 Binary Search Pythonで2分探索を実装します。 二分探索(にぶんたんさく、英: binary search、BS)やバイナリサーチとは、ソート済み配列に対する探索アルゴリズムの一つ。 出典: フリー百科事典『ウィキペディア(Wikip...

記事を読む

[Python] ABC017 A

問題 A - プロコン 回答 s1, e1 = map(int, input().split()) s2, e2 = map(int, input().split()) s3, e3 = map(int, input().split()) sum_sco...

記事を読む

[統計] 仮説検定

以下の私的まとめです。 Decisions and Uncertainty あるデータが得られたときに、そのデータは偶然によるものなのか、偶然以外のものによるものなのか、どちらか判断するときに、仮説検定という手法を用います。 仮説検定(かせつけんてい、英:hy...

記事を読む


Public Domain YottaGin No Rights Reserved.