結果

問題 No.854 公平なりんご分配
ユーザー pekempeypekempey
提出日時 2019-08-01 19:24:20
言語 F#
(F# 4.0)
結果
AC  
実行時間 1,221 ms / 3,153 ms
コード長 1,693 bytes
コンパイル時間 3,564 ms
コンパイル使用メモリ 168,360 KB
実行使用メモリ 47,824 KB
最終ジャッジ日時 2023-09-18 17:54:58
合計ジャッジ時間 36,570 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
24,728 KB
testcase_01 AC 77 ms
22,808 KB
testcase_02 AC 77 ms
22,616 KB
testcase_03 AC 76 ms
22,728 KB
testcase_04 AC 77 ms
22,708 KB
testcase_05 AC 76 ms
22,704 KB
testcase_06 AC 78 ms
24,752 KB
testcase_07 AC 77 ms
24,712 KB
testcase_08 AC 77 ms
22,656 KB
testcase_09 AC 77 ms
22,620 KB
testcase_10 AC 78 ms
24,748 KB
testcase_11 AC 78 ms
22,744 KB
testcase_12 AC 78 ms
24,680 KB
testcase_13 AC 76 ms
22,712 KB
testcase_14 AC 77 ms
24,612 KB
testcase_15 AC 77 ms
24,700 KB
testcase_16 AC 77 ms
24,756 KB
testcase_17 AC 77 ms
22,720 KB
testcase_18 AC 77 ms
22,636 KB
testcase_19 AC 78 ms
22,820 KB
testcase_20 AC 77 ms
24,800 KB
testcase_21 AC 77 ms
24,688 KB
testcase_22 AC 84 ms
24,712 KB
testcase_23 AC 82 ms
24,724 KB
testcase_24 AC 87 ms
22,840 KB
testcase_25 AC 83 ms
24,896 KB
testcase_26 AC 87 ms
22,720 KB
testcase_27 AC 84 ms
24,764 KB
testcase_28 AC 84 ms
22,832 KB
testcase_29 AC 80 ms
22,724 KB
testcase_30 AC 80 ms
22,648 KB
testcase_31 AC 85 ms
22,704 KB
testcase_32 AC 185 ms
40,576 KB
testcase_33 AC 201 ms
39,200 KB
testcase_34 AC 295 ms
41,436 KB
testcase_35 AC 230 ms
42,712 KB
testcase_36 AC 194 ms
31,168 KB
testcase_37 AC 179 ms
40,792 KB
testcase_38 AC 155 ms
40,404 KB
testcase_39 AC 412 ms
41,704 KB
testcase_40 AC 219 ms
36,956 KB
testcase_41 AC 231 ms
40,352 KB
testcase_42 AC 269 ms
43,784 KB
testcase_43 AC 315 ms
42,416 KB
testcase_44 AC 322 ms
40,756 KB
testcase_45 AC 334 ms
37,028 KB
testcase_46 AC 397 ms
44,968 KB
testcase_47 AC 195 ms
45,148 KB
testcase_48 AC 253 ms
41,316 KB
testcase_49 AC 242 ms
43,552 KB
testcase_50 AC 172 ms
40,992 KB
testcase_51 AC 394 ms
43,432 KB
testcase_52 AC 346 ms
41,588 KB
testcase_53 AC 225 ms
39,236 KB
testcase_54 AC 341 ms
40,488 KB
testcase_55 AC 171 ms
37,092 KB
testcase_56 AC 153 ms
40,320 KB
testcase_57 AC 204 ms
38,868 KB
testcase_58 AC 325 ms
33,956 KB
testcase_59 AC 142 ms
31,264 KB
testcase_60 AC 254 ms
42,988 KB
testcase_61 AC 174 ms
31,124 KB
testcase_62 AC 282 ms
39,888 KB
testcase_63 AC 263 ms
41,828 KB
testcase_64 AC 135 ms
27,332 KB
testcase_65 AC 219 ms
40,588 KB
testcase_66 AC 203 ms
33,092 KB
testcase_67 AC 297 ms
42,600 KB
testcase_68 AC 313 ms
37,552 KB
testcase_69 AC 210 ms
43,348 KB
testcase_70 AC 160 ms
34,740 KB
testcase_71 AC 175 ms
35,896 KB
testcase_72 AC 242 ms
27,064 KB
testcase_73 AC 206 ms
42,572 KB
testcase_74 AC 354 ms
43,104 KB
testcase_75 AC 214 ms
38,020 KB
testcase_76 AC 315 ms
40,560 KB
testcase_77 AC 309 ms
41,624 KB
testcase_78 AC 341 ms
38,700 KB
testcase_79 AC 345 ms
43,008 KB
testcase_80 AC 320 ms
41,176 KB
testcase_81 AC 265 ms
40,420 KB
testcase_82 AC 1,189 ms
43,840 KB
testcase_83 AC 1,192 ms
43,632 KB
testcase_84 AC 1,200 ms
45,692 KB
testcase_85 AC 1,221 ms
43,696 KB
testcase_86 AC 1,062 ms
47,824 KB
testcase_87 AC 1,186 ms
45,688 KB
testcase_88 AC 1,198 ms
47,732 KB
testcase_89 AC 1,179 ms
47,720 KB
testcase_90 AC 1,191 ms
43,684 KB
testcase_91 AC 1,182 ms
45,864 KB
testcase_92 AC 1,196 ms
45,720 KB
testcase_93 AC 1,193 ms
45,784 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 reader = new StreamReader(new BufferedStream(Console.OpenStandardInput ()))

let read f = 
  while reader.Peek () <= int ' ' do reader.Read () |> ignore
  [|while reader.Peek () > int ' ' do yield char (reader.Read ())|] |> System.String |> f

let read_int () =
  while reader.Peek () <= int ' ' do reader.Read () |> ignore
  let mutable ans = 0
  while reader.Peek () > int ' ' do
    ans <- ans * 10 + (reader.Read () - 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