QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140837 | #5158. Interview Question | Mohamed_Hamed# | Compile Error | / | / | C++14 | 2.0kb | 2023-08-16 21:11:20 | 2023-08-16 21:11:22 |
Judging History
answer
# ﷽
import sys
input = lambda: sys.stdin.readline().strip()
def inlst():return [int(i) for i in input().split()]
class PrimeFactorisation:
def __init__(self, mx):
self.mx = mx
self.primes = []
self.factor = [-1] * (mx + 1)
for i in range(2, mx + 1):
if self.factor[i] == -1:
self.primes += [i]
for j in range(i, mx + 1, i):
self.factor[j] = i
def factorise(self, n):
"""Returns a list of tuples (prime, exponent) representing the prime factorisation of n."""
prime_factorisation = []
while n > 1:
prime, exp = self.factor[n], 0
while n % prime == 0:
exp += 1
n //= prime
prime_factorisation += [(prime, exp)]
return prime_factorisation
def divisors(self,n):
"""returns a list of all distinct factors of n"""
factors = [1]
for p, exp in self.factorise(n):
factors += [p**i * factor for factor in factors for i in range(1, exp + 1)]
return factors
pf=PrimeFactorisation(1+10**5)
def solve():
a,b=inlst()
lst=input().split()
s1=set()
s2=set()
u,v=0,0
for i in range(a,b+1):
if lst[i-a] =='Fizz' or lst[i-a] =='FizzBuzz':
tmp=set()
for h,k in pf.factorise(i):tmp.add(h)
if u==0:s1=tmp.copy();u=1
else:s1=s1.intersection(tmp)
if lst[i-a]=='Buzz' or lst[i-a] =='FizzBuzz':
tmp=set()
for h,k in pf.factorise(i):tmp.add(h)
if v==0:s2=tmp.copy();v=1
else:s2=s2.intersection(tmp)
aa=s1.difference(s2)
bb=s2.difference(s1)
if aa:an=list(aa)[0]
else:an=1
if bb:bn=list(bb)[0]
else:bn=1
if an==1 and bn==1:
an=3
bn=5
# print(b)
# print(aa,bb)
# print(s1,s2)
print(an,bn)
if __name__ == "__main__":
# for i in range(int(input())):
solve()
詳細信息
answer.code:1:3: error: invalid preprocessing directive #\U0000fdfd 1 | # ﷽ | ^ answer.code:40:23: warning: multi-character character constant [-Wmultichar] 40 | if lst[i-a] =='Fizz' or lst[i-a] =='FizzBuzz': | ^~~~~~ answer.code:40:44: warning: character constant too long for its type 40 | if lst[i-a] =='Fizz' or lst[i-a] =='FizzBuzz': | ^~~~~~~~~~ answer.code:45:23: warning: multi-character character constant [-Wmultichar] 45 | if lst[i-a]=='Buzz' or lst[i-a] =='FizzBuzz': | ^~~~~~ answer.code:45:44: warning: character constant too long for its type 45 | if lst[i-a]=='Buzz' or lst[i-a] =='FizzBuzz': | ^~~~~~~~~~ answer.code:59:7: error: invalid preprocessing directive #print 59 | # print(b) | ^~~~~ answer.code:60:7: error: invalid preprocessing directive #print 60 | # print(aa,bb) | ^~~~~ answer.code:61:7: error: invalid preprocessing directive #print 61 | # print(s1,s2) | ^~~~~ answer.code:72:7: error: invalid preprocessing directive #for 72 | # for i in range(int(input())): | ^~~ answer.code:2:1: error: ‘import’ does not name a type 2 | import sys | ^~~~~~ answer.code:2:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’ answer.code:43:35: error: ‘u’ does not name a type 43 | if u==0:s1=tmp.copy();u=1 | ^ answer.code:48:35: error: ‘v’ does not name a type 48 | if v==0:s2=tmp.copy();v=1 | ^