結果

問題 No.415 ぴょん
ユーザー ichibanshiboriichibanshibori
提出日時 2016-09-05 23:05:20
言語 OCaml
(5.1.0)
結果
TLE  
実行時間 -
コード長 759 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 21,120 KB
実行使用メモリ 138,028 KB
最終ジャッジ日時 2023-09-07 22:49:59
合計ジャッジ時間 4,062 ms
ジャッジサーバーID
(参考情報)
judge3 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

open Big_int_Z

module BISet = Set.Make( 
    struct
        let compare = compare_big_int
        type t = big_int
    end )

let ( +! ) = add_big_int
let ( %! ) = mod_big_int

let () =
    let arr = Array.make 2 zero_big_int in
    Scanf.scanf "%s %s\n" (fun n d -> arr.(0) <- big_int_of_string n; arr.(1) <- big_int_of_string d);

    let n, d = arr.(0), arr.(1) in
    let rec count_pyon pos hist count =
        let next_pos, next_hist = (pos +! d) %! n, BISet.add pos hist in
        if BISet.mem next_pos next_hist then string_of_big_int count
        else
            let next_count = count +! unit_big_int in
            count_pyon next_pos  next_hist next_count
    in
    count_pyon zero_big_int BISet.empty zero_big_int |>
    Printf.printf "%s\n"
0