题解-luogu-p1080国王游戏

题目链接

高精度怎能少了Python3题解。。。

贪心策略一楼dalao已经讲得很清楚了,上一发超短代码(学Python就是为了水高精)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
N=int(input())
s=input().split()
S=int(s[0])
T=int(s[1])
a=[]
for i in range(1,N+1):
k=input().split()
a.append((int(k[0]),int(k[1])))
a.sort(key=lambda x:x[0]*x[1])
ans=0
for i in range(0,N):
if(S//(a[i])[1]>ans):
ans=S//(a[i])[1]
S*=(a[i])[0]
print(ans)

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×