結果

問題 No.864 四方演算
ユーザー pekempeypekempey
提出日時 2019-08-16 21:35:33
言語 OCaml
(5.1.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 529 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 21,320 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:48:36
合計ジャッジ時間 1,603 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 13 ms
5,376 KB
testcase_02 AC 10 ms
5,376 KB
testcase_03 AC 11 ms
5,376 KB
testcase_04 AC 12 ms
5,376 KB
testcase_05 AC 9 ms
5,376 KB
testcase_06 AC 12 ms
5,376 KB
testcase_07 AC 10 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 14 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 11 ms
5,376 KB
testcase_18 AC 11 ms
5,376 KB
testcase_19 AC 9 ms
5,376 KB
testcase_20 AC 13 ms
5,376 KB
testcase_21 AC 10 ms
5,376 KB
testcase_22 AC 9 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 8 ms
5,376 KB
testcase_25 AC 6 ms
5,376 KB
testcase_26 AC 10 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 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