QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670776#9225. Fibonacci Fusion27568WA 9ms10740kbPython31.5kb2024-10-24 00:59:302024-10-24 00:59:31

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 00:59:31]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:10740kb
  • [2024-10-24 00:59:30]
  • 提交

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)
    return calc(n)

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)[0] - aj + P) % P, 0)
    ans += mp.get((Fio(i + 1)[0] - aj + P) % P, 0)
    ans += mp.get((Fio(i + 2)[0] - aj + P) % P, 0)
    ans += mp.get((Fio(i + 3)[0] - aj + P) % P, 0)

    if mp.get(aj, 0) == 0:
        mp.update({aj:1})
    else:
        mp[aj] += 1


print(ans)
print(len(mp))

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 10740kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4
6

result:

wrong answer Output contains longer sequence [length = 2], but answer contains 1 elements