結果
問題 | No.300 平方数 |
ユーザー |
![]() |
提出日時 | 2015-11-13 23:46:41 |
言語 | OCaml (5.2.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 679 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 19,564 KB |
実行使用メモリ | 18,808 KB |
最終ジャッジ日時 | 2024-10-08 23:41:28 |
合計ジャッジ時間 | 2,243 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 RE * 22 |
ソースコード
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 (1000000 + (int_of_float (sqrt (float_of_int n)))) 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)