結果

問題 No.864 四方演算
ユーザー pekempeypekempey
提出日時 2019-08-16 21:35:33
言語 OCaml
(4.13.1)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 529 bytes
コンパイル時間 218 ms
使用メモリ 3,188 KB
最終ジャッジ日時 2022-12-01 20:45:29
合計ジャッジ時間 2,643 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
2,976 KB
testcase_01 AC 13 ms
3,188 KB
testcase_02 AC 9 ms
2,964 KB
testcase_03 AC 11 ms
3,044 KB
testcase_04 AC 11 ms
3,168 KB
testcase_05 AC 9 ms
3,144 KB
testcase_06 AC 11 ms
3,028 KB
testcase_07 AC 10 ms
3,040 KB
testcase_08 AC 10 ms
3,144 KB
testcase_09 AC 6 ms
3,040 KB
testcase_10 AC 6 ms
3,180 KB
testcase_11 AC 3 ms
2,948 KB
testcase_12 AC 9 ms
3,040 KB
testcase_13 AC 7 ms
3,040 KB
testcase_14 AC 4 ms
3,040 KB
testcase_15 AC 13 ms
2,968 KB
testcase_16 AC 10 ms
3,152 KB
testcase_17 AC 12 ms
2,992 KB
testcase_18 AC 10 ms
3,076 KB
testcase_19 AC 8 ms
3,056 KB
testcase_20 AC 12 ms
2,984 KB
testcase_21 AC 10 ms
3,184 KB
testcase_22 AC 9 ms
3,124 KB
testcase_23 AC 2 ms
2,944 KB
testcase_24 AC 8 ms
3,060 KB
testcase_25 AC 5 ms
2,988 KB
testcase_26 AC 9 ms
3,128 KB
testcase_27 AC 1 ms
3,128 KB
testcase_28 AC 1 ms
3,140 KB
testcase_29 AC 1 ms
3,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

open Scanf
open Printf

let divs n =
  let ans = ref [] in
  let i = ref 1 in
  while !i * !i <= n do
    if n mod !i = 0 then begin
      ans := !i :: !ans;
      if !i * !i < n then ans := (n / !i) :: !ans;
    end;
    incr i;
  done;
  !ans

let () =
  let n, k = scanf "%d %d" (fun x y -> x, y) in
  divs k |> List.map (fun x ->
    let y = k / x in
    let ax = max 0 (min n (x - 1) - max 1 (x - n) + 1) in
    let ay = max 0 (min n (y - 1) - max 1 (y - n) + 1) in
    ax * ay)
  |> List.fold_left (+) 0
  |> printf "%d\n"
0