QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#316881#8177. Sum is Integerucup-team2000#RE 0ms0kbPython31.1kb2024-01-28 05:28:392024-01-28 05:28:40

Judging History

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

  • [2024-01-28 05:28:40]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-01-28 05:28:39]
  • 提交

answer

import io,os,sys
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
input = sys.stdin.readline
p1 = 23513892331597
p2 = 999998727899999
p3 = 19489355557003

pn = []
qn = []
n = int(input())
for i in range(n):
    x, y = list(map(int, input().split()))
    pn.append(x)
    qn.append(y)

def get_array(p):
    arr = [(pn[i] * pow(qn[i], p-2,p)) % p for i in range(n)]
    for i in range(1,n):
        arr[i] = (arr[i] + arr[i-1]) % p
    return arr

A = get_array(p1)
B = get_array(p2)
C = get_array(p3)
all = [A,B,C]

k = 2 

res = []
for i in range(n):
    vals = []
    for ii in range(k):
        for jj in range(ii+1,k):
            vals.append(all[ii][i] - all[jj][i])
    # print(vals)
    res.append(vals)
res.append([0 for i in range(k) for j in range(i+1,k)])
res = list(sorted(res))

# print(res)

ans = 0



for i in range(n+1):
    if i > 0 and res[i] == res[i-1]:
        continue
    j = i
    while j + 1 < n+1 and res[j+1] == res[i]:
        j += 1
    # print(f"i: {i}, j: {j}")
    len = j - i + 1
    ans += (len) * (len - 1) // 2

print(ans)


詳細信息

Test #1:

score: 0
Dangerous Syscalls

input:

4
1 6
1 3
1 2
1 2

output:


result: