思路:思维。我们贪心地想:如果,那么肯定是买单只更好;如果
,我们优先买
只,最终还剩下mod只需要购买。此时就需要进行讨论,由于题目说的是至少,因此我们买的数量是可以超的。那就判断一下,剩下数量买单只的花费
与直接买3只的花费
,哪个小就选择哪个。最终,输出结果即可
代码:
import sys
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
'''
def solve():
a, b, x = LII()
if 3 * a <= b:
ans = a * x
else:
div, mod = divmod(x, 3)
ans = div * b
if a * mod <= b:
ans += a * mod
else:
ans += b
print(ans)
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号