QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#670782 | #9225. Fibonacci Fusion | 27568 | WA | 2079ms | 45124kb | Python3 | 1.5kb | 2024-10-24 01:16:14 | 2024-10-24 01:16:15 |
Judging History
answer
import sys
sys.set_int_max_str_digits(0)
import math
sq5 = math.sqrt(5)
P = 1000000000000002097
fio = [0, 1]
for i in range(50):
fio.append((fio[-1] + fio[-2]) % P)
def mul(m1, m2):
m3 = [
[(m1[0][0] * m2[0][0] + m1[0][1] * m2[1][0]) % P, (m1[0][0] * m2[0][1] + m1[0][1] * m2[1][1]) % P],
[(m1[1][0] * m2[0][0] + m1[1][1] * m2[1][0]) % P, (m1[1][0] * m2[0][1] + m1[1][1] * m2[1][1]) % P]
]
return m3
def Fio(n):
def calc(n):
if n == 0:
return (0, 1)
else:
a, b = calc(n // 2)
c = (a * ((2 * b - a) % P)) % P
d = (a * a + b * b) % P
if n % 2 == 0:
return (c, d)
else:
return (d, (c + d) % P)
if n <= 20:
return fio[n]
return calc(n - 1)[0]
def get(x):
if x <= 20:
y = 1
while True:
if fio[y] >= x:
return y
y += 1
return math.ceil((math.log10(sq5) + math.log10(x)) / math.log10((1 + sq5) / 2))
n = int(input())
a = [int(input()) for _ in range(n)]
a = sorted(a)
ans = 0
mp = {-1:0}
for aj in a:
i = get(aj)
aj %= P
ans += mp.get((Fio(i) - aj + P) % P, 0)
ans += mp.get((Fio(i + 1) - aj + P) % P, 0)
ans += mp.get((Fio(i + 2) - aj + P) % P, 0)
ans += mp.get((Fio(i + 3) - aj + P) % P, 0)
if mp.get(aj, 0) == 0:
mp.update({aj:1})
else:
mp[aj] += 1
print(ans)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 10732kb
input:
6 50 8 8 5 72 354224848179261915070
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 825ms
memory: 20904kb
input:
28 200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...
output:
27
result:
ok 1 number(s): "27"
Test #3:
score: 0
Accepted
time: 157ms
memory: 13568kb
input:
5187 2640352926124261912741724778991366987330659389621881876017670644497364093930668042530271338851702874394631009332660937266680740235862107353443518003194307853104942996827176097428402408674756368623972812842571069642405111849826172879369776309763468485788964245903781380419155348915131587410703749...
output:
6073
result:
ok 1 number(s): "6073"
Test #4:
score: 0
Accepted
time: 570ms
memory: 14212kb
input:
200000 2 2 2 2 1 2 1 1 2 2 1 1 1 2 2 1 1 2 1 1 2 2 1 2 2 2 1 1 1 1 2 2 1 2 1 2 1 1 2 2 1 1 1 2 1 1 2 1 2 2 2 2 1 2 2 1 1 1 2 1 1 1 1 1 2 1 2 2 1 1 1 2 2 2 1 1 2 1 1 2 1 2 1 1 1 2 2 2 1 1 1 1 2 1 2 1 1 2 2 1 1 2 1 1 2 1 2 2 1 2 1 2 2 1 1 2 1 1 1 2 2 2 1 2 2 1 1 2 2 2 2 1 2 1 1 2 1 2 2 1 1 1 1 2 2 2 2...
output:
15003749259
result:
ok 1 number(s): "15003749259"
Test #5:
score: 0
Accepted
time: 2079ms
memory: 45124kb
input:
200000 944176313232170622314 2590599414036674999101 753315073608896000424 9299685298577430049245 9361800333778142620806 8988699166328904060999 9606920674025578304023 4203331868598952026136 5183047027116137697788 3968714342776915029801 8130984095583566992354 3206443643596048048798 6248561214283254355...
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: -100
Wrong Answer
time: 1068ms
memory: 18440kb
input:
200000 9 10 3 5 9 3 3 9 8 5 1 2 7 8 4 6 2 3 3 9 5 5 4 9 7 5 8 2 6 10 9 7 2 2 1 10 10 6 10 7 4 7 9 7 2 2 10 4 5 8 2 2 5 8 9 5 3 9 2 1 7 6 8 8 6 3 8 2 2 9 10 2 9 7 1 9 1 4 5 9 2 7 10 1 8 7 4 8 1 10 6 4 4 9 1 9 7 3 6 5 6 9 5 3 6 6 4 4 6 1 8 6 10 3 10 2 1 4 1 4 8 2 9 1 4 8 10 8 2 2 3 6 4 7 10 10 9 4 7 6...
output:
4388645476
result:
wrong answer 1st numbers differ - expected: '4388485679', found: '4388645476'