結果
| 問題 |
No.854 公平なりんご分配
|
| コンテスト | |
| ユーザー |
双六
|
| 提出日時 | 2020-08-12 02:03:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,169 bytes |
| コンパイル時間 | 200 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,700 KB |
| 最終ジャッジ日時 | 2024-10-09 12:26:02 |
| 合計ジャッジ時間 | 12,866 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 TLE * 1 -- * 59 |
ソースコード
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")
def getlist():
return list(map(int, input().split()))
class SegmentTree(object):
def __init__(self, N):
self.N = N
self.N0 = 2 ** (N - 1).bit_length()
self.initVal = 1
self.data = [self.initVal] * (2 * self.N0)
def calc(self, a, b):
return a * b
def initialize(self, A):
for i in range(self.N):
self.data[self.N0 - 1 + i] = A[i]
for i in range(self.N0 - 2, -1, -1):
self.data[i] = self.calc(self.data[2 * i + 1], self.data[2 * i + 2])
def query(self, l, r):
L = l + self.N0; R = r + self.N0 + 1
m = self.initVal
while L < R:
if R & 1:
R -= 1
m = self.calc(m, self.data[R - 1])
if L & 1:
m = self.calc(m, self.data[L - 1])
L += 1
L >>= 1; R >>= 1
return m
#処理内容
def main():
N = int(input())
A = getlist()
Seg = SegmentTree(N)
Seg.initialize(A)
Q = int(input())
for i in range(Q):
P, L, R = getlist()
L -= 1; R -= 1
cross = Seg.query(L, R)
if cross % P == 0:
print("Yes")
else:
print("NO")
if __name__ == '__main__':
main()
双六