結果
問題 | No.300 平方数 |
ユーザー |
![]() |
提出日時 | 2015-11-14 00:42:11 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 667 bytes |
コンパイル時間 | 360 ms |
コンパイル使用メモリ | 19,820 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 23:41:40 |
合計ジャッジ時間 | 1,689 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
let rec factriz i ls n =if i * i > n then n :: lselseif i = 2 thenif n mod 2 = 0 then factriz i (i :: ls) (n / i)else factriz (i+1) ls nelseif n mod i = 0 thenfactriz i (i :: ls) (n / i)elsefactriz (i+2) ls nlet rec matchls n = function[] ->true|hd :: tl -> if n <> hd then matchls n tlelse falselet 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 ()) inprint_int (main (factriz 2 [] n) [])