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] 双方向リスト

以下を参考にしています。 Data-Structures-using-Python/Linked Lists/DoublyLinkedList.py 双方向リスト 片方向リストは後方向へのリンクだけでしたが、双方向リスト(Doubly-Linked List)...

記事を読む

[Python] ABC017 B

問題 B - choku語 回答 X = input() while X: if len(X)>=2 and X == 'ch': X = X elif X == 'o' or X == 'k' or X == 'u': ...

記事を読む

[Python] ABC017 C 101点 いもす法

問題 C – ハイスコア 回答 スライドに従っていもす法を使います。 AtCoder Beginner Contest 017 解説 from AtCoder Inc. N, M = map(int, input().spl...

記事を読む

[Python] Punctuationの一括削除

punctuationとは、記号文字列のことです。 str.translate() を使う方法と、正規表現を使う方法で行ってみます。 str.translate() を使うPunctuationの削除 str.translate()を使い、Punctuat...

記事を読む

[Python] ABC015 A

問題 A - 高橋くんの研修 回答 A = input() B = input() if len(A) > len (B): print(A) else: print(B)

記事を読む


Public Domain YottaGin No Rights Reserved.