QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#669554 | #9225. Fibonacci Fusion | Legend_dy# | Compile Error | / | / | C++20 | 1.3kb | 2024-10-23 18:59:38 | 2024-10-23 18:59:41 |
Judging History
answer
import math
sq5 = math.sqrt(5)
P = 1000000000000000007
fio = [0, 1]
for i in range(50):
fio.append((fio[-1] + fio[-2]) % P)
def mul(m1, m2):
m3 = [[0, 0], [0, 0]]
for i in range(0, 2):
for j in range(0, 2):
for k in range(0, 2):
m3[i][j] += m1[i][k] * m2[k][j]
m3[i][j] %= P
return m3
def Fio(n):
if n <= 20:
return fio[n]
y = [[1, 0], [0, 1]]
x = [[0, 1], [1, 1]]
while n > 0:
if n % 2 == 1:
y = mul(y, x)
x = mul(x, x)
n //= 2
return y[0][0]
def get(x):
if x <= 20:
y = 0
while True:
if fio[y] >= x:
return y
y += 1
return math.ceil((math.log2(sq5) + math.log2(x)) / math.log2((1 + sq5) / 2))
n = int(input())
# n = 10
a = []
for i in range(0, n):
a.append(int(input()))
# a.append(10**100000)
a = sorted(a)
ans = 0
mp = {-1:0}
for j in range(0, n):
i = get(a[j])
a[j] %= P
ans += mp.get((Fio(i) - a[j] + P) % P, 0)
ans += mp.get((Fio(i + 1) - a[j] + P) % P, 0)
ans += mp.get((Fio(i + 2) - a[j] + P) % P, 0)
if mp.get(a[j], 0) == 0:
mp.update({a[j]:1})
else:
mp[a[j]] += 1
print(ans)
Details
answer.code:42:3: error: invalid preprocessing directive #n 42 | # n = 10 | ^ answer.code:46:7: error: invalid preprocessing directive #a 46 | # a.append(10**100000) | ^ answer.code:1:1: error: ‘import’ does not name a type 1 | import math | ^~~~~~ answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’, which is not yet enabled with ‘-std=c++20’ answer.code:53:1: error: expected unqualified-id before ‘for’ 53 | for j in range(0, n): | ^~~ answer.code:61:27: error: expected unqualified-id before ‘)’ token 61 | mp.update({a[j]:1}) | ^