package main import ( "fmt" ) func min(x, y int64) int64 { if y > x { return x } return y } func main() { var A, B, T int64 fmt.Scan(&A, &B, &T) if B > A { A, B = B, A } res := int64(1) << 60 x := T / A if A*x < T { x++ } for ; x >= 0; x-- { y := int64(0) if T-x*A > 0 { y = (T - A*x) / B } if A*x+B*y < T { y++ } res = min(res, A*x+B*y) if y > A { break } } fmt.Println(res) }