QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#878726 | #9690. Iron Warrior | ucup-team5243# | AC ✓ | 232ms | 9216kb | Python3 | 1.8kb | 2025-02-01 17:06:56 | 2025-02-01 17:06:57 |
Judging History
answer
def mat_mul(a, b) :
I, J, K = len(a), len(b[0]), len(b)
c = [[0] * J for _ in range(I)]
for i in range(I) :
for j in range(J) :
for k in range(K) :
c[i][j] += a[i][k] * b[k][j]
return c
def mat_pow(x, n):
y = [[0] * len(x) for _ in range(len(x))]
for i in range(len(x)):
y[i][i] = 1
while n > 0:
if n & 1:
y = mat_mul(x, y)
x = mat_mul(x, x)
n >>= 1
return y
N = int(input())
if N <= 3:
print([20,42,72,105,145,208,248,343,393,517,569,749,809,1022,1092][N-1])
exit()
body = [[1,0,1,0],[5,1,0,0],[0,0,1,0],[0,0,0,1]]
pommel = [[1,0,0,0],[5,1,0,0],[0,0,1,0],[0,0,10,1]]
shrug = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[11,0,0,1]]
rage = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,1,0,1]]
def solve(arg):
now = [[0,0,0,1]]
if N%2 == 1:
now = mat_mul(now,mat_mul(mat_mul(rage,body),mat_mul(pommel,shrug)))
cnt = (N-3)//2
else:
now = mat_mul(now,mat_mul(rage,shrug))
cnt = (N-2)//2
if arg > cnt:
return [[0,0,-10**18,0]]
X = mat_mul(rage,mat_mul(pommel,shrug))
Y = mat_mul(body,mat_mul(pommel,shrug))
now = mat_mul(now, mat_pow(X,arg))
now = mat_mul(now, mat_pow(Y,cnt-arg))
now = mat_mul(now,body)
now = mat_mul(now,pommel)
now = mat_mul(now,body)
return (now)
if N%2 == 1:
tmp = (N-3)//2
else:
tmp = (N-2)//2
def sanbu():
low = 0
high = tmp+1
ans = -float("inf")
while low<high:
M1 = (low*2+high)//3
M2 = (low+high*2)//3
A1 = solve(M1)[0][2]
A2 = solve(M2)[0][2]
ans = max(A1,A2,ans)
if A1<A2:
low = M1+1
else:
high = M2-1
return ans
print(sanbu())
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 8ms
memory: 8832kb
input:
1
output:
20
result:
ok answer is '20'
Test #2:
score: 0
Accepted
time: 11ms
memory: 8832kb
input:
3
output:
72
result:
ok answer is '72'
Test #3:
score: 0
Accepted
time: 9ms
memory: 8960kb
input:
4
output:
105
result:
ok answer is '105'
Test #4:
score: 0
Accepted
time: 10ms
memory: 9088kb
input:
5
output:
145
result:
ok answer is '145'
Test #5:
score: 0
Accepted
time: 9ms
memory: 8960kb
input:
6
output:
208
result:
ok answer is '208'
Test #6:
score: 0
Accepted
time: 10ms
memory: 8960kb
input:
7
output:
248
result:
ok answer is '248'
Test #7:
score: 0
Accepted
time: 9ms
memory: 8960kb
input:
8
output:
343
result:
ok answer is '343'
Test #8:
score: 0
Accepted
time: 29ms
memory: 9216kb
input:
486036
output:
13810882446441423
result:
ok answer is '13810882446441423'
Test #9:
score: 0
Accepted
time: 34ms
memory: 9088kb
input:
857503
output:
75842693981321486
result:
ok answer is '75842693981321486'
Test #10:
score: 0
Accepted
time: 31ms
memory: 9088kb
input:
459087
output:
11638561802272893
result:
ok answer is '11638561802272893'
Test #11:
score: 0
Accepted
time: 32ms
memory: 9088kb
input:
326354
output:
4181111331905669
result:
ok answer is '4181111331905669'
Test #12:
score: 0
Accepted
time: 34ms
memory: 9088kb
input:
755041
output:
51774938180590304
result:
ok answer is '51774938180590304'
Test #13:
score: 0
Accepted
time: 34ms
memory: 9088kb
input:
1000000
output:
120283726342420340
result:
ok answer is '120283726342420340'
Test #14:
score: 0
Accepted
time: 63ms
memory: 9088kb
input:
562451495
output:
21401951468280078633294014
result:
ok answer is '21401951468280078633294014'
Test #15:
score: 0
Accepted
time: 54ms
memory: 9216kb
input:
100214615
output:
121057415160393160185480
result:
ok answer is '121057415160393160185480'
Test #16:
score: 0
Accepted
time: 60ms
memory: 9088kb
input:
726997959
output:
46216571009844858875968944
result:
ok answer is '46216571009844858875968944'
Test #17:
score: 0
Accepted
time: 66ms
memory: 9088kb
input:
883477562
output:
82943950684199531529718356
result:
ok answer is '82943950684199531529718356'
Test #18:
score: 0
Accepted
time: 61ms
memory: 8960kb
input:
456878752
output:
11470993586298146794567272
result:
ok answer is '11470993586298146794567272'
Test #19:
score: 0
Accepted
time: 64ms
memory: 9216kb
input:
1000000000
output:
120281308501417045326995605
result:
ok answer is '120281308501417045326995605'
Test #20:
score: 0
Accepted
time: 224ms
memory: 9088kb
input:
151798318021627311
output:
420725672820572820226091469784149314525410684999074
result:
ok answer is '420725672820572820226091469784149314525410684999074'
Test #21:
score: 0
Accepted
time: 228ms
memory: 9088kb
input:
466154514052238226
output:
12183941850211915347991952173009567537536253846445099
result:
ok answer is '12183941850211915347991952173009567537536253846445099'
Test #22:
score: 0
Accepted
time: 223ms
memory: 8960kb
input:
262261097390039057
output:
2169700342816432479937347535029836266637820523889883
result:
ok answer is '2169700342816432479937347535029836266637820523889883'
Test #23:
score: 0
Accepted
time: 225ms
memory: 9088kb
input:
409768988622482114
output:
8275903133852517858111731626726122320253985666412809
result:
ok answer is '8275903133852517858111731626726122320253985666412809'
Test #24:
score: 0
Accepted
time: 230ms
memory: 9088kb
input:
361773749401383499
output:
5695204039674250675619463634360070429230287130689713
result:
ok answer is '5695204039674250675619463634360070429230287130689713'
Test #25:
score: 0
Accepted
time: 232ms
memory: 8960kb
input:
1000000000000000000
output:
120281306081172036692984324273260313737335405903162447
result:
ok answer is '120281306081172036692984324273260313737335405903162447'
Extra Test:
score: 0
Extra Test Passed