QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#319291 | #7146. Geometric progression | testerhellow | WA | 439ms | 88076kb | Python3 | 629b | 2024-02-02 12:51:28 | 2024-02-02 12:51:28 |
Judging History
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'