結果
| 問題 | No.101 ぐるぐる!あみだくじ! |
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2020-12-06 22:34:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 5,000 ms |
| コード長 | 387 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 61,824 KB |
| 最終ジャッジ日時 | 2024-09-17 13:20:12 |
| 合計ジャッジ時間 | 3,129 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
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)
convexineq