結果
問題 |
No.500 階乗電卓
|
ユーザー |
|
提出日時 | 2020-07-09 00:46:22 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 21,524 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 01:48:49 |
合計ジャッジ時間 | 1,260 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
Scanf.scanf "%d" (fun n -> let k = 1_000_000_000_000 in let rec loop i acc overflow = if acc mod k = 0 then print_endline "000000000000" else if i > n then (if overflow then Printf.printf "%012d\n" acc else Printf.printf "%d\n" acc ) else let acc = acc * i in if acc >= k then loop (i + 1) (acc mod k) true else loop (i + 1) acc overflow in loop 1 1 false )