結果
問題 |
No.300 平方数
|
ユーザー |
![]() |
提出日時 | 2015-11-13 23:07:40 |
言語 | OCaml (5.2.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 634 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 19,692 KB |
実行使用メモリ | 525,284 KB |
最終ジャッジ日時 | 2024-10-08 23:40:19 |
合計ジャッジ時間 | 2,606 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 2 |
other | AC * 5 RE * 37 MLE * 1 |
ソースコード
let rec factriz i ls n = if i * i > n then n :: ls else if n mod i = 0 then factriz i (i :: ls) (n / i) else factriz (i+1) ls n let arr n = Array.make (n/2) 0 let counter ls arr = for i = 0 to List.length ls - 1 do arr.(List.nth ls i) <- arr.(List.nth ls i) + 1 done let rec main arr ls i = if i > Array.length arr - 1 then List.fold_left (fun x y -> x * y) 1 ls else if arr.(i) mod 2 = 0 then main arr ls (i+1) else main arr (i :: ls) (i+1) let () = let n = int_of_string (read_line ()) in let arr = arr n in let facts = factriz 2 [] n in counter facts arr; print_int (main arr [] 0)