F题容易想到依次统计每个质数在1~n上出现的总次数,可以使用二分确定最小的n,但是容易TLE,所以联想到等比数列的求和公式:
注意实际求和需要下取整,但不妨先使用该公式进行近似比较
from bisect import * primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541 ] class PrimeCounter: def __init__(self,prime): self.prime = prime def __len__(self): return 1 << 60 def __getitem__(self,index): count = 0 while index: index //= self.prime count += index return count def main(): for _ in range(int(input())): n = int(input()) s = list(map(int,input().split())) _,p,c = max(((p-1)*c,p,c) for p,c in zip(primes,s)) ans = bisect_left(PrimeCounter(p),c) print(ans) main()