結果
問題 |
No.101 ぐるぐる!あみだくじ!
|
ユーザー |
|
提出日時 | 2025-08-22 13:55:10 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 487 bytes |
コンパイル時間 | 2,024 ms |
コンパイル使用メモリ | 197,688 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-22 13:55:15 |
合計ジャッジ時間 | 3,761 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
ソースコード
module main; // https://kmjp.hatenablog.jp/entry/2014/12/12/0900 より import std; void main() { // 入力 int N = readln.chomp.to!int; int K = readln.chomp.to!int; auto R = iota(0, N).array; foreach (_; 0 .. K) { int x, y; readln.chomp.formattedRead("%d %d", x, y); swap(R[x - 1], R[y - 1]); } // 答えの計算と出力 long ans = 1; foreach (i; 0 .. N) { long x, y; for (x = i, y = 0; y == 0 || x != i; y++) x = R[x]; ans = lcm(ans, y); } writeln(ans); }