結果

問題 No.854 公平なりんご分配
ユーザー pekempeypekempey
提出日時 2019-08-01 17:03:04
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 1,381 bytes
コンパイル時間 3,484 ms
コンパイル使用メモリ 152,332 KB
実行使用メモリ 41,336 KB
最終ジャッジ日時 2023-09-18 17:29:14
合計ジャッジ時間 27,591 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
22,760 KB
testcase_01 AC 84 ms
22,884 KB
testcase_02 AC 84 ms
22,812 KB
testcase_03 AC 85 ms
22,968 KB
testcase_04 AC 84 ms
22,812 KB
testcase_05 AC 85 ms
22,716 KB
testcase_06 AC 85 ms
24,892 KB
testcase_07 AC 84 ms
22,820 KB
testcase_08 AC 86 ms
22,880 KB
testcase_09 AC 85 ms
24,844 KB
testcase_10 AC 84 ms
22,956 KB
testcase_11 AC 84 ms
22,692 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 85 ms
22,764 KB
testcase_15 AC 85 ms
22,712 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 84 ms
22,880 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 AC 683 ms
35,024 KB
testcase_83 WA -
testcase_84 WA -
testcase_85 AC 754 ms
39,408 KB
testcase_86 AC 651 ms
35,356 KB
testcase_87 AC 677 ms
39,008 KB
testcase_88 AC 679 ms
37,060 KB
testcase_89 AC 676 ms
39,144 KB
testcase_90 AC 684 ms
37,068 KB
testcase_91 AC 683 ms
41,336 KB
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let read_line () = stdin.ReadLine()
let read_tokens () = read_line().Split ' '

let N = read_line () |> int
let A = read_tokens () |> Array.map int
let Q = read_line () |> 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
  let p, l, r = read_tokens () |> (fun a -> int a.[0], int a.[1], int a.[2])
  P.[i] <- p
  L.[i] <- l - 1
  R.[i] <- r
  zero.[L.[i]] <- zero.[L.[i]] + 1
  zero.[R.[i]] <- zero.[R.[i]] - 1

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..10 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