結果
問題 |
No.854 公平なりんご分配
|
ユーザー |
![]() |
提出日時 | 2023-10-23 21:35:00 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,074 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 82,004 KB |
実行使用メモリ | 283,512 KB |
最終ジャッジ日時 | 2024-09-22 15:03:42 |
合計ジャッジ時間 | 18,734 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 RE * 26 TLE * 1 -- * 41 |
ソースコード
import sys input = sys.stdin.readline from math import * def Sieve(n): lst = [True] * (n + 1) S = set() for i in range(2, ceil(sqrt(n)) + 1): if lst[i]: for j in range(2 * i, n + 1, i): lst[j] = False for i in range(2, n + 1): if lst[i]: S.add(i) return sorted(list(S)) N = int(input()) A = list(map(int, input().split())) Prime = Sieve(3000) M = len(Prime) D = [[0] * N for _ in range(M)] Dc = [[0] * (N + 1) for _ in range(M)] for i in range(M): for j in range(N): while A[j] % Prime[i] == 0: A[j] //= Prime[i] D[i][j] += 1 for j in range(N): Dc[i][j + 1] = Dc[i][j] + D[i][j] Q = int(input()) for _ in range(Q): P, L, R = map(int, input().split()) L -= 1 for i in range(N): cnt = 0 while P % Prime[i] == 0: cnt += 1 P //= Prime[i] if cnt > Dc[i][R] - Dc[i][L]: print("NO") break else: print("Yes") if P == 1 else print("NO")