結果
問題 | No.756 チャンパーノウン定数 (1) |
ユーザー |
|
提出日時 | 2018-12-06 12:19:45 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 674 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 21,536 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 00:32:33 |
合計ジャッジ時間 | 1,132 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
let rec calc2 d num bse =if (Int64.compare d 0L)==0 then (Int64.rem num bse) else (calc2 (Int64.sub d 1L) (Int64.div num bse) bse);;let rec calc digits expbase bse x n =if (Int64.compare x n)>0 then (calc2 (Int64.sub (Int64.sub digits 1L) (Int64.rem n digits)) (Int64.add expbase (Int64.div n digits)) bse) else(calc (Int64.add digits 1L) (Int64.mul expbase bse) bse (Int64.mul (Int64.mul (Int64.add digits 1L) (Int64.mul expbase bse)) (Int64.sub bse 1L)) (Int64.sub n x));;trywhile true doScanf.sscanf (read_line ()) "%Ld" (fun n ->print_string (Int64.to_string (calc 1L 1L 10L 9L (Int64.sub n 1L)));print_string "\n")done;with End_of_file -> ();;