結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー convexineqconvexineq
提出日時 2020-12-06 22:34:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 387 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 81,484 KB
実行使用メモリ 63,272 KB
最終ジャッジ日時 2023-10-17 15:39:18
合計ジャッジ時間 4,627 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,616 KB
testcase_01 AC 53 ms
63,272 KB
testcase_02 AC 53 ms
63,272 KB
testcase_03 AC 39 ms
53,616 KB
testcase_04 AC 38 ms
53,616 KB
testcase_05 AC 53 ms
63,272 KB
testcase_06 AC 38 ms
53,616 KB
testcase_07 AC 46 ms
55,664 KB
testcase_08 AC 46 ms
55,664 KB
testcase_09 AC 44 ms
55,664 KB
testcase_10 AC 44 ms
55,664 KB
testcase_11 AC 44 ms
55,664 KB
testcase_12 AC 48 ms
55,664 KB
testcase_13 AC 52 ms
61,224 KB
testcase_14 AC 45 ms
55,664 KB
testcase_15 AC 46 ms
55,664 KB
testcase_16 AC 50 ms
61,224 KB
testcase_17 AC 47 ms
55,664 KB
testcase_18 AC 44 ms
55,664 KB
testcase_19 AC 45 ms
55,664 KB
testcase_20 AC 43 ms
55,664 KB
testcase_21 AC 48 ms
55,664 KB
testcase_22 AC 44 ms
55,664 KB
testcase_23 AC 52 ms
63,272 KB
testcase_24 AC 43 ms
55,664 KB
testcase_25 AC 52 ms
61,224 KB
testcase_26 AC 53 ms
63,272 KB
testcase_27 AC 52 ms
61,224 KB
testcase_28 AC 44 ms
55,664 KB
testcase_29 AC 52 ms
63,272 KB
testcase_30 AC 50 ms
61,224 KB
testcase_31 AC 52 ms
61,224 KB
testcase_32 AC 46 ms
55,664 KB
testcase_33 AC 52 ms
63,272 KB
testcase_34 AC 37 ms
53,616 KB
testcase_35 AC 37 ms
53,616 KB
testcase_36 AC 37 ms
53,616 KB
testcase_37 AC 38 ms
53,616 KB
testcase_38 AC 38 ms
53,616 KB
testcase_39 AC 38 ms
53,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
k = int(input())

r = list(range(n))
for _ in range(k):
    x,y = map(int,input().split())
    r[x-1],r[y-1] = r[y-1],r[x-1]

from math import gcd
def lcm(x,y): return x//gcd(x,y)*y

ans = 1
used = [0]*n
for i in range(n):
    if used[i]: continue
    cnt = 0
    while used[i]==0:
        used[i] = 1
        i = r[i]
        cnt += 1
    ans = lcm(ans,cnt)

print(ans)
0