結果
問題 | No.854 公平なりんご分配 |
ユーザー | vwxyz |
提出日時 | 2024-04-08 07:29:44 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,257 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 261,060 KB |
最終ジャッジ日時 | 2024-10-01 04:58:17 |
合計ジャッジ時間 | 18,627 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | RE | - |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | RE | - |
testcase_82 | RE | - |
testcase_83 | RE | - |
testcase_84 | RE | - |
testcase_85 | RE | - |
testcase_86 | RE | - |
testcase_87 | RE | - |
testcase_88 | RE | - |
testcase_89 | RE | - |
testcase_90 | RE | - |
testcase_91 | RE | - |
testcase_92 | RE | - |
testcase_93 | RE | - |
ソースコード
class Prime: def __init__(self,N): assert N<=10**8 self.smallest_prime_factor=[None]*(N+1) for i in range(2,N+1,2): self.smallest_prime_factor[i]=2 n=int(N**.5)+1 for p in range(3,n,2): if self.smallest_prime_factor[p]==None: self.smallest_prime_factor[p]=p for i in range(p**2,N+1,2*p): if self.smallest_prime_factor[i]==None: self.smallest_prime_factor[i]=p for p in range(n,N+1): if self.smallest_prime_factor[p]==None: self.smallest_prime_factor[p]=p self.primes=[p for p in range(N+1) if p==self.smallest_prime_factor[p]] def Factorize(self,N): assert N>=1 factors=defaultdict(int) if N<=len(self.smallest_prime_factor)-1: while N!=1: factors[self.smallest_prime_factor[N]]+=1 N//=self.smallest_prime_factor[N] else: for p in self.primes: while N%p==0: N//=p factors[p]+=1 if N<p*p: if N!=1: factors[N]+=1 break if N<=len(self.smallest_prime_factor)-1: while N!=1: factors[self.smallest_prime_factor[N]]+=1 N//=self.smallest_prime_factor[N] break else: if N!=1: factors[N]+=1 return factors def Divisors(self,N): assert N>0 divisors=[1] for p,e in self.Factorize(N).items(): pow_p=[1] for _ in range(e): pow_p.append(pow_p[-1]*p) divisors=[i*j for i in divisors for j in pow_p] return divisors def Is_Prime(self,N): return N==self.smallest_prime_factor[N] def Totient(self,N): for p in self.Factorize(N).keys(): N*=p-1 N//=p return N def Mebius(self,N): fact=self.Factorize(N) for e in fact.values(): if e>=2: return 0 else: if len(fact)%2==0: return 1 else: return -1 N=int(input()) A=list(map(int,input().split())) max_A=max(A) Pr=Prime(max_A) Q=int(input()) ans_lst=["Yes"]*Q P,L,R=[],[],[] for q in range(Q): p,l,r=map(int,input().split()) l-=1 P.append(p) L.append(l) R.append(r) cumsum0=[0]*(N+1) for i in range(N): if A[i]==0: cumsum0[i+1]=1 for i in range(1,N+1): cumsum0[i]+=cumsum0[i-1] for p in Pr.primes: cumsum=[0]*(N+1) for i in range(N): if A[i]: while A[i]%p==0: cumsum[i+1]+=1 A[i]//=p for i in range(1,N+1): cumsum[i]+=cumsum[i-1] for q in range(Q): if cumsum0[R[q]]-cumsum0[L[q]]: continue cnt=0 while P[q]%p==0: P[q]//=p cnt+=1 if cumsum[R]-cumsum[L]<cnt: ans_lst[q]="NO" for q in range(Q): if cumsum0[R]-cumsum0[L]: continue if P[q]>=2: ans_lst[q]="NO" print(*ans_lst,sep="\n")