QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#878714 | #9690. Iron Warrior | ucup-team055# | AC ✓ | 482ms | 9216kb | Python3 | 1.6kb | 2025-02-01 17:02:34 | 2025-02-01 17:02:34 |
Judging History
answer
R = [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 5, 1]
]
B = [
[1, 1, 0, 0],
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 0, 0, 1]
]
P = [
[1, 0, 0, 0],
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 10, 0, 1]
]
S = [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[11, 0, 0, 1]
]
def mul(a, b):
c = [[0 for i in range(4)] for j in range(4)]
for i in range(4):
for j in range(4):
for k in range(4):
c[i][k] += a[i][j] * b[j][k]
return c
def my_pow(a, times):
res = [[(1 if i == j else 0) for i in range(4)] for j in range(4)]
while times:
if times & 1:
res = mul(res, a)
times //= 2
a = mul(a, a)
return res
SRP = mul(S, mul(R, P))
SBP = mul(S, mul(B, P))
def simple(st, en, a, b):
res = mul(st, mul(my_pow(SRP, a), mul(my_pow(SBP, b), en)))
return res[3][1]
def solve(st, en, rem):
if rem < 0:
return 0
rem //= 2
lef = 0
rig = rem
res = 0
while rig - lef > 2:
mid1 = lef + (rig - lef) // 3
mid2 = rig - (rig - lef) // 3
if simple(st, en, mid1, rem - mid1) >= simple(st, en, mid2, rem - mid2):
rig = mid2
else:
lef = mid1
for i in range(lef, rig + 1):
res = max(res, simple(st, en, i, rem - i))
return res
def calc(N):
ans = 0
ans = max(ans, solve(R, B, N))
RBP = mul(R, mul(B, P))
ans = max(ans, solve(RBP, B, N - 1))
return ans
N = int(input())
print(calc(N))
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 9ms
memory: 8960kb
input:
1
output:
20
result:
ok answer is '20'
Test #2:
score: 0
Accepted
time: 12ms
memory: 9216kb
input:
3
output:
72
result:
ok answer is '72'
Test #3:
score: 0
Accepted
time: 9ms
memory: 9088kb
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: 11ms
memory: 8960kb
input:
6
output:
208
result:
ok answer is '208'
Test #6:
score: 0
Accepted
time: 11ms
memory: 9088kb
input:
7
output:
248
result:
ok answer is '248'
Test #7:
score: 0
Accepted
time: 10ms
memory: 8960kb
input:
8
output:
343
result:
ok answer is '343'
Test #8:
score: 0
Accepted
time: 52ms
memory: 9216kb
input:
486036
output:
13810882446441423
result:
ok answer is '13810882446441423'
Test #9:
score: 0
Accepted
time: 62ms
memory: 8960kb
input:
857503
output:
75842693981321486
result:
ok answer is '75842693981321486'
Test #10:
score: 0
Accepted
time: 57ms
memory: 9088kb
input:
459087
output:
11638561802272893
result:
ok answer is '11638561802272893'
Test #11:
score: 0
Accepted
time: 52ms
memory: 9088kb
input:
326354
output:
4181111331905669
result:
ok answer is '4181111331905669'
Test #12:
score: 0
Accepted
time: 62ms
memory: 9088kb
input:
755041
output:
51774938180590304
result:
ok answer is '51774938180590304'
Test #13:
score: 0
Accepted
time: 62ms
memory: 9216kb
input:
1000000
output:
120283726342420340
result:
ok answer is '120283726342420340'
Test #14:
score: 0
Accepted
time: 118ms
memory: 9088kb
input:
562451495
output:
21401951468280078633294014
result:
ok answer is '21401951468280078633294014'
Test #15:
score: 0
Accepted
time: 100ms
memory: 9088kb
input:
100214615
output:
121057415160393160185480
result:
ok answer is '121057415160393160185480'
Test #16:
score: 0
Accepted
time: 120ms
memory: 9088kb
input:
726997959
output:
46216571009844858875968944
result:
ok answer is '46216571009844858875968944'
Test #17:
score: 0
Accepted
time: 122ms
memory: 9088kb
input:
883477562
output:
82943950684199531529718356
result:
ok answer is '82943950684199531529718356'
Test #18:
score: 0
Accepted
time: 118ms
memory: 8960kb
input:
456878752
output:
11470993586298146794567272
result:
ok answer is '11470993586298146794567272'
Test #19:
score: 0
Accepted
time: 122ms
memory: 9088kb
input:
1000000000
output:
120281308501417045326995605
result:
ok answer is '120281308501417045326995605'
Test #20:
score: 0
Accepted
time: 455ms
memory: 9088kb
input:
151798318021627311
output:
420725672820572820226091469784149314525410684999074
result:
ok answer is '420725672820572820226091469784149314525410684999074'
Test #21:
score: 0
Accepted
time: 472ms
memory: 9216kb
input:
466154514052238226
output:
12183941850211915347991952173009567537536253846445099
result:
ok answer is '12183941850211915347991952173009567537536253846445099'
Test #22:
score: 0
Accepted
time: 456ms
memory: 9216kb
input:
262261097390039057
output:
2169700342816432479937347535029836266637820523889883
result:
ok answer is '2169700342816432479937347535029836266637820523889883'
Test #23:
score: 0
Accepted
time: 459ms
memory: 9216kb
input:
409768988622482114
output:
8275903133852517858111731626726122320253985666412809
result:
ok answer is '8275903133852517858111731626726122320253985666412809'
Test #24:
score: 0
Accepted
time: 471ms
memory: 9088kb
input:
361773749401383499
output:
5695204039674250675619463634360070429230287130689713
result:
ok answer is '5695204039674250675619463634360070429230287130689713'
Test #25:
score: 0
Accepted
time: 482ms
memory: 8960kb
input:
1000000000000000000
output:
120281306081172036692984324273260313737335405903162447
result:
ok answer is '120281306081172036692984324273260313737335405903162447'
Extra Test:
score: 0
Extra Test Passed