結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー HIROPON87069639HIROPON87069639
提出日時 2016-02-16 21:28:12
言語 Python2
(2.7.18)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 687 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 7,124 KB
実行使用メモリ 6,540 KB
最終ジャッジ日時 2023-10-22 06:01:39
合計ジャッジ時間 1,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,512 KB
testcase_01 AC 14 ms
6,540 KB
testcase_02 AC 14 ms
6,540 KB
testcase_03 AC 14 ms
6,516 KB
testcase_04 AC 14 ms
6,516 KB
testcase_05 AC 15 ms
6,536 KB
testcase_06 AC 12 ms
6,512 KB
testcase_07 AC 13 ms
6,524 KB
testcase_08 AC 14 ms
6,524 KB
testcase_09 AC 13 ms
6,520 KB
testcase_10 AC 13 ms
6,520 KB
testcase_11 AC 15 ms
6,524 KB
testcase_12 AC 16 ms
6,532 KB
testcase_13 AC 15 ms
6,540 KB
testcase_14 AC 15 ms
6,524 KB
testcase_15 AC 15 ms
6,528 KB
testcase_16 AC 16 ms
6,536 KB
testcase_17 AC 15 ms
6,532 KB
testcase_18 AC 15 ms
6,524 KB
testcase_19 AC 16 ms
6,528 KB
testcase_20 AC 15 ms
6,524 KB
testcase_21 AC 15 ms
6,532 KB
testcase_22 AC 14 ms
6,528 KB
testcase_23 AC 16 ms
6,540 KB
testcase_24 AC 15 ms
6,524 KB
testcase_25 AC 16 ms
6,540 KB
testcase_26 AC 16 ms
6,540 KB
testcase_27 AC 16 ms
6,540 KB
testcase_28 AC 15 ms
6,524 KB
testcase_29 AC 16 ms
6,540 KB
testcase_30 AC 15 ms
6,536 KB
testcase_31 AC 15 ms
6,540 KB
testcase_32 AC 15 ms
6,528 KB
testcase_33 AC 16 ms
6,540 KB
testcase_34 AC 11 ms
6,512 KB
testcase_35 AC 11 ms
6,512 KB
testcase_36 AC 11 ms
6,512 KB
testcase_37 AC 13 ms
6,516 KB
testcase_38 AC 13 ms
6,516 KB
testcase_39 AC 13 ms
6,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b / gcd(a, b)

N = input()
K = input()
Alist = [i+1 for i in range(0, N)]
Blist = [i+1 for i in range(0, N)]
Clist = [0 for i in range(0, N)]
Klist = [0 for i in range(0, K)]
for i in range(0, K):
    Klist[i] = map(int, raw_input().split())[0] - 1
for i in Klist:
        Blist[i], Blist[i+1] = Blist[i+1], Blist[i]
cnt = 0
for i in range(0, N):
    cnt += 1
    for j in range(0, N):
        Alist[j] = Blist[Alist[j]-1]
        if Clist[j] == 0 and Alist[j] == j+1:
            Clist[j] = cnt
cnt = 1
for i in range(0, N):
    cnt = lcm(cnt, Clist[i])
print cnt
0