結果

問題 No.176 2種類の切手
ユーザー ぴろず
提出日時 2015-04-02 23:59:56
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 488 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 78,572 KB
実行使用メモリ 54,372 KB
最終ジャッジ日時 2024-10-08 01:50:45
合計ジャッジ時間 8,381 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

package no176;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long t = sc.nextInt();
		long max = Math.min(a-1, (t+b-1)/b);
		long ans = Long.MAX_VALUE;
		for(int y=0;y<max;y++) {
			long x;
			if (b * y >= t) {
				x = 0;
			}else{
				x = (t - (long)b * y + a - 1) / a;
			}
			ans = Math.min(a * x + b * y, ans);
		}
		System.out.println(ans);
	}

}
0