結果

問題 No.854 公平なりんご分配
ユーザー pekempeypekempey
提出日時 2019-08-01 19:31:44
言語 F#
(F# 4.0)
結果
AC  
実行時間 1,198 ms / 3,153 ms
コード長 1,674 bytes
コンパイル時間 3,898 ms
コンパイル使用メモリ 160,712 KB
実行使用メモリ 57,612 KB
最終ジャッジ日時 2023-09-18 17:57:41
合計ジャッジ時間 37,754 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
34,568 KB
testcase_01 AC 89 ms
30,484 KB
testcase_02 AC 90 ms
32,400 KB
testcase_03 AC 89 ms
32,448 KB
testcase_04 AC 90 ms
32,520 KB
testcase_05 AC 90 ms
30,468 KB
testcase_06 AC 91 ms
32,400 KB
testcase_07 AC 90 ms
32,536 KB
testcase_08 AC 90 ms
32,440 KB
testcase_09 AC 89 ms
32,432 KB
testcase_10 AC 91 ms
32,624 KB
testcase_11 AC 90 ms
32,604 KB
testcase_12 AC 90 ms
32,360 KB
testcase_13 AC 91 ms
34,568 KB
testcase_14 AC 93 ms
34,612 KB
testcase_15 AC 93 ms
32,452 KB
testcase_16 AC 90 ms
32,400 KB
testcase_17 AC 89 ms
32,588 KB
testcase_18 AC 92 ms
34,464 KB
testcase_19 AC 90 ms
34,424 KB
testcase_20 AC 89 ms
32,512 KB
testcase_21 AC 90 ms
34,416 KB
testcase_22 AC 95 ms
32,416 KB
testcase_23 AC 96 ms
32,604 KB
testcase_24 AC 99 ms
34,492 KB
testcase_25 AC 94 ms
34,452 KB
testcase_26 AC 99 ms
34,532 KB
testcase_27 AC 96 ms
34,500 KB
testcase_28 AC 97 ms
34,564 KB
testcase_29 AC 92 ms
34,416 KB
testcase_30 AC 94 ms
30,584 KB
testcase_31 AC 98 ms
32,376 KB
testcase_32 AC 183 ms
48,780 KB
testcase_33 AC 209 ms
44,268 KB
testcase_34 AC 294 ms
53,116 KB
testcase_35 AC 232 ms
52,996 KB
testcase_36 AC 208 ms
38,788 KB
testcase_37 AC 182 ms
53,008 KB
testcase_38 AC 158 ms
47,332 KB
testcase_39 AC 415 ms
51,696 KB
testcase_40 AC 232 ms
42,092 KB
testcase_41 AC 235 ms
52,140 KB
testcase_42 AC 268 ms
53,384 KB
testcase_43 AC 326 ms
51,004 KB
testcase_44 AC 326 ms
52,956 KB
testcase_45 AC 353 ms
42,096 KB
testcase_46 AC 403 ms
53,200 KB
testcase_47 AC 203 ms
46,004 KB
testcase_48 AC 250 ms
52,884 KB
testcase_49 AC 241 ms
55,332 KB
testcase_50 AC 179 ms
51,028 KB
testcase_51 AC 397 ms
50,992 KB
testcase_52 AC 359 ms
45,204 KB
testcase_53 AC 235 ms
44,504 KB
testcase_54 AC 352 ms
49,736 KB
testcase_55 AC 178 ms
42,396 KB
testcase_56 AC 160 ms
45,400 KB
testcase_57 AC 214 ms
42,360 KB
testcase_58 AC 345 ms
41,652 KB
testcase_59 AC 152 ms
42,584 KB
testcase_60 AC 268 ms
44,492 KB
testcase_61 AC 187 ms
40,728 KB
testcase_62 AC 294 ms
42,872 KB
testcase_63 AC 278 ms
41,120 KB
testcase_64 AC 147 ms
37,088 KB
testcase_65 AC 218 ms
50,792 KB
testcase_66 AC 218 ms
41,028 KB
testcase_67 AC 306 ms
49,992 KB
testcase_68 AC 327 ms
40,552 KB
testcase_69 AC 203 ms
53,092 KB
testcase_70 AC 166 ms
40,328 KB
testcase_71 AC 182 ms
43,132 KB
testcase_72 AC 255 ms
38,976 KB
testcase_73 AC 207 ms
52,780 KB
testcase_74 AC 353 ms
53,412 KB
testcase_75 AC 224 ms
45,428 KB
testcase_76 AC 328 ms
53,084 KB
testcase_77 AC 312 ms
53,188 KB
testcase_78 AC 360 ms
42,508 KB
testcase_79 AC 357 ms
53,060 KB
testcase_80 AC 326 ms
52,292 KB
testcase_81 AC 273 ms
54,480 KB
testcase_82 AC 1,166 ms
53,412 KB
testcase_83 AC 1,165 ms
55,464 KB
testcase_84 AC 1,168 ms
57,612 KB
testcase_85 AC 1,198 ms
53,460 KB
testcase_86 AC 1,036 ms
55,508 KB
testcase_87 AC 1,158 ms
53,424 KB
testcase_88 AC 1,171 ms
53,460 KB
testcase_89 AC 1,156 ms
55,468 KB
testcase_90 AC 1,162 ms
55,500 KB
testcase_91 AC 1,164 ms
53,460 KB
testcase_92 AC 1,170 ms
53,480 KB
testcase_93 AC 1,171 ms
55,424 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System
open System.Text
open System.IO
open System.Collections.Generic

let buf = Array.create 5000000 ' '
let mutable bufn = 0
let mutable bufk = 0

let peek () =
  if bufk = bufn then
    bufn <- stdin.Read(buf, 0, buf.Length)
    bufk <- 0
  int buf.[bufk]

let next () = 
  let ans = buf.[bufk]
  bufk <- bufk + 1
  int ans

let read_int () =
  while peek () <= int ' ' do next () |> ignore
  let mutable ans = 0
  while peek () > int ' ' do
    ans <- ans * 10 + (next () - int '0')
  ans

let N = read_int ()
let A = Array.init N (fun _ -> read_int ())
let Q = read_int ()

let P = Array.zeroCreate Q
let L = Array.zeroCreate Q
let R = Array.zeroCreate Q
let zero = Array.zeroCreate (N+1)
for i in 0..Q-1 do
  P.[i] <- read_int ()
  L.[i] <- read_int () - 1
  R.[i] <- read_int ()
for i in 0..N-1 do zero.[i+1] <- zero.[i] + (if A.[i] = 0 then 1 else 0)
for i in 0..Q-1 do if zero.[R.[i]] - zero.[L.[i]] > 0 then P.[i] <- 1

let table = Array.create 2001 true
let primes = new ResizeArray<int>()
table.[0] <- false
table.[1] <- false
for i in 2..2000 do
  if table.[i] then
    primes.Add(i)
    for j in 2*i..i..2000 do table.[j] <- false
let ans = Array.create Q true
for p in primes do
  let cnt = Array.zeroCreate (N+1)
  for i in 0..N-1 do
    let mutable k = 0
    while A.[i] <> 0 && A.[i] % p = 0 do
      A.[i] <- A.[i] / p
      k <- k + 1
    cnt.[i+1] <- cnt.[i] + k
  for i in 0..Q-1 do
    let mutable k = 0
    while P.[i] % p = 0 do
      P.[i] <- P.[i] / p
      k <- k + 1
    if cnt.[R.[i]] - cnt.[L.[i]] < k then
      ans.[i] <- false

for i in 0..Q-1 do
  if P.[i] <> 1 then ans.[i] <- false
  printfn "%s" (if ans.[i] then "Yes" else "NO")
0