結果

問題 No.300 平方数
ユーザー agatan
提出日時 2015-11-13 23:30:01
言語 OCaml
(5.2.1)
結果
TLE  
実行時間 -
コード長 372 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 19,680 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-10-08 23:40:11
合計ジャッジ時間 3,192 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 TLE * 1 -- * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

let rec f c xs n =
  if n = 1 then
    xs
  else if n mod c = 0 then
    f c (c :: xs) (n / c)
  else
    f (c + 1) xs n

let x = read_int ()

let innsuu = f 2 [] x

let rec g rs = function
  | [] -> rs
  | a :: b :: xs when a = b -> g rs xs
  | a :: xs -> g (a :: rs) xs

let answer = g [] innsuu

let () =
  print_int (List.fold_left ( * ) 1 answer);
  print_newline ()
0