QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#437616 | #8786. The Whole World | ucup-team1004 | TL | 11ms | 10680kb | Python3 | 974b | 2024-06-09 14:10:12 | 2024-06-09 14:10:13 |
Judging History
answer
T=int(input())
def binom(n,m):
if 0>n or m>n:
return 0
ans=1
for i in range(m):
ans=ans*(n-i)//(i+1)
return ans
while T>0:
n=int(input())
x=[0 for i in range(n)]
y=[0 for i in range(n)]
for i in range(n):
x[i],y[i]=map(int,input().split(' '))
a=[[0 for j in range(n)] for i in range(n)]
def insert(a,n,x):
for i in range(n):
while x[i]:
w=a[i][i]//x[i]
for j in range(i,n):
a[i][j]-=x[j]*w
a[i],x=x,a[i]
for i in range(n):
if a[i][i]==0:
continue
for j in range(i):
w=a[j][i]/a[i][i]
for k in range(i,n):
a[j][k]-=a[i][k]*w
def check(a,n,x):
for i in range(n):
if x[i]==0:
continue
if a[i][i]==0 or x[i]%a[i][i]!=0:
return 0
w=x[i]//a[i][i]
for j in range(i,n):
x[j]-=a[i][j]*w
return 1
ans=0
while 1:
v=[]
for i in range(n):
v.append(binom(x[i],ans))
insert(a,n,v)
if check(a,n,y):
print(ans)
break
ans+=1
T-=1
詳細信息
Test #1:
score: 100
Accepted
time: 11ms
memory: 10620kb
input:
2 2 1 0 4 1 3 1 1 4 4 6 6
output:
3 1
result:
ok 2 number(s): "3 1"
Test #2:
score: 0
Accepted
time: 7ms
memory: 10680kb
input:
2 2 1 0 4 1 3 1 0 3 0 5 4
output:
3 3
result:
ok 2 number(s): "3 3"
Test #3:
score: -100
Time Limit Exceeded
input:
2 10 1 557 2 -172 3 -497 5 763 6 -149 7 -355 8 -29 9 -588 10 -171 11 -355 10 1 -461 2 -219 3 -45 4 -212 5 749 6 -294 9 -85 10 213 11 -412 12 125