結果

問題 No.176 2種類の切手
ユーザー tnoda_
提出日時 2015-04-03 19:01:04
言語 Go
(1.23.4)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 427 bytes
コンパイル時間 14,134 ms
コンパイル使用メモリ 242,860 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-10 03:36:52
合計ジャッジ時間 12,461 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
}
0