QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#319291#7146. Geometric progressiontesterhellowWA 439ms88076kbPython3629b2024-02-02 12:51:282024-02-02 12:51:28

Judging History

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

  • [2024-02-02 12:51:28]
  • 评测
  • 测评结果:WA
  • 用时:439ms
  • 内存:88076kb
  • [2024-02-02 12:51:28]
  • 提交

answer

import math
from bisect import*
n,*a=map(int,open(0).read().split())
M=10**6+1
d=[[]for()in[[]]*M]
for i,x in enumerate(a):d[x].append(i)
for i in d:i.sort()
ans=0
for i in range(1, M):
    if not d[i]:continue
    if len(d[i])>2:ans+=math.comb(len(d[i]),3)
    k=2
    while k*k*i<M:
        if not d[i*k]:k+=1;continue
        if not d[i*k*k]:k+=1;continue
        lj,sj=len(d[i*k]),0
        for z in reversed(d[i]):
            jj=bisect(d[i*k],z)
            while lj>jj:
                lj-=1
                sj+=len(d[i*k*k])-bisect(d[i*k*k],d[i*k][jj])
            ans+=sj
        k+=1
print(ans)

详细

Test #1:

score: 100
Accepted
time: 425ms
memory: 88076kb

input:

3
1 2 4

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 439ms
memory: 87988kb

input:

4
1 2 4 8

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Wrong Answer
time: 425ms
memory: 87948kb

input:

10
4 5 6 7 8 9 10 12 14 15

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'