結果
問題 |
No.300 平方数
|
ユーザー |
![]() |
提出日時 | 2015-11-14 00:26:53 |
言語 | OCaml (5.2.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 665 bytes |
コンパイル時間 | 433 ms |
コンパイル使用メモリ | 19,820 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-08 23:41:34 |
合計ジャッジ時間 | 1,838 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 10 WA * 33 |
ソースコード
let rec factriz i ls n = if i * i > n then n :: ls else if i = 2 then if n mod 2 = 0 then factriz i (i :: ls) (n / i) else factriz (i+1) ls n else if n mod i = 0 then factriz i (i :: ls) (n / i) else factriz (i+2) ls n let rec matchls n = function [] ->true |hd :: tl -> if n = hd then matchls n tl else false let rec main ls ls1 = match ls with [] -> List.fold_left (fun x y -> x * y) 1 ls1 |hd :: tl -> if matchls hd ls1 = false then main tl (List.filter ((fun x y -> x = y) hd) ls1) else main tl (hd :: ls1) let () = let n = int_of_string (read_line ()) in print_int (main (factriz 3 [] n) [])