結果
| 問題 | No.101 ぐるぐる!あみだくじ! | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-01-02 09:04:01 | 
| 言語 | Python2 (2.7.18) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 15 ms / 5,000 ms | 
| コード長 | 367 bytes | 
| コンパイル時間 | 215 ms | 
| コンパイル使用メモリ | 7,040 KB | 
| 実行使用メモリ | 6,272 KB | 
| 最終ジャッジ日時 | 2024-12-16 03:06:12 | 
| 合計ジャッジ時間 | 2,257 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 | 
ソースコード
#yuki101 a=[[0 for i in range(100)] for j in range(2)] r=[] def gcd(a, b): while b: a, b = b, a % b return a n=int(raw_input()) k=int(raw_input()) for i in range(n): r.append(i) while k: x,y=map(int,raw_input().split()) r[x-1],r[y-1]=r[y-1],r[x-1] k-=1 res=1 for i in range(n): x=i y=0 while y==0 or x!=i: x=r[x] y+=1 res=res*y/gcd(res,y) print res
